Reputation: 529
I am trying set a variable's value inside ng click which is not working.
<a href="#newpage" ng-click="service.name='{{sub.cid}}'"> view</a>
But when i use plain text instead of angular data value it works fine.
<a href="#newpage" ng-click="service.name='abc'">
What is wrong in my code ?
Upvotes: 0
Views: 157
Reputation: 506
Create a function and set values there. Remove logic from template
<a href="#newpage" ng-click="changeValue(sub.cid)"> view</a>
<a href="#newpage" ng-click="changeValue('abc')"> view</a>
function changeValue(val) {
ctrl.service.name = val;
}
Upvotes: 1
Reputation: 133453
Remove string interpolation and directly use sub.cid
<a href="#newpage" ng-click="service.name=sub.cid"> view</a>
Upvotes: 1