Issue
Below code in controller and a function getSug(). all this code is inside a angular controller. onclick event doesn't invoke getSug() function. How do i invoke it?
var vm = this;
var quant ="linkClick";
vm.link = '<a onclick="'+vm.getSug();+'">' + quant + '</a>';
function getSug(){}
html: <table>
<tr>
<th>link</th>
</tr>
<tr>
<td ng-bind-html="vm.link"></td>
</tr>
</table>
Solution
In angularjs, onclick is ng-click
Also you wouldn't write your html that way in angular. Rather it would be:
<table>
<tr>
<th>link</th>
</tr>
<tr>
<td>
<a ng-if='quant' ng-click="getSug()" ng-bind-html="quant"></a>
</td>
</tr>
</table>
Then your function would live in the controller that was associated with that page:
$scope.getSug = function() {
// code
}
Answered By - Kinglish
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.