Suppose I have a link:

a data-pressed="false" ng-click="func(...)" 

How to transfer data-pressed value in func ?

  • @ alexsemen1994, If you are given an exhaustive answer, mark it as correct (click on the check mark next to the selected answer). - Nicolas Chabanovsky
  • How will you use true or false in the click function? Or do you want to customize whether the function will work on a click or not? - MasterAlex

2 answers 2

In this case - no way.

Instead of passing an attribute, you should pass the parameter directly:

 a ng-click="func(false)" 

The same works if an angular expression was used for the attribute value.

 a ng-click="func(expression)" 

    Like this:

     data-pressed="false" ng-click="func($(this).data('pressed'))" 
    • it does not work, because in ng-click an angular expression is passed, in this is not an element, but scope , besides all functions and variables in the markup are taken from the scope, and if there is no $ property in it, then the global variable $ not will be used - Grundy