javascript - AngularJS - using data binding {{}} in ng-click -
Is there a way to change dynamically the way a ng-click is called?
/ P>
$ scope. Function call = "call infunction (param)"; From , ngClick evaluates expressions in the context of the scope. Dont stop nothing from referring to a function, but I'm not sure that this is the desired method, I would probably call a function explicitly and such as ng-click = 'myfunction (myParams) Instead of '
, the behavior will switch on a parameter basis. Nonetheless, this is an example of what you have to achieve.
HTML
& lt; Div ng-app = 'foo' ng-controller = 'ctrl' & gt; & Lt; Div ng-click = 'this [myVar] ()' & gt; {{Times}} & lt; / Div & gt; & Lt; / Div & gt;
javascript
var app = angular Module ('foo', []). Controller ('ctrl', function ($ scope) {$ Scope.myVar = 'callIt'; $ scope.bar = 'first'; $ scope.callIt = function () {$ scope.bar = 'after';}} );
Comments
Post a Comment