Angular.js Parsing Value In Ng-click
I have a list of actions in a child controller: $scope.actions = [{action:'onClick()',name:'Test'}]; On a browse template i have a button dropdown group that looks like this: <
Solution 1:
Edit: my bad, you don't have a typo.
You don't need {{}}
if it's an attribute of the element. But I'm really not sure what you expect to happen when you try to call a string, it needs to be a function.
Try something like this:
var someFunc = function() {
console.log("someFunc")
};
$scope.actions = [{action:someFunc,name:"Test"}];
<ling-repeat="action in actions"><ahref=""ng-click="action.action()">{{action.name}}</a></li>
Working demo.
Solution 2:
Did you define onClick function, something like
$scope.onClick = function() {
alert('clicked!');
};
BTW, original syntax for ngClick is correct, without double curly brackets.
Post a Comment for "Angular.js Parsing Value In Ng-click"