Shesha Shesha - 1 year ago 123
Ajax Question

How to use template value while calling function?


<li data-id="{{Name.first}}" ng-click="getNames('{{Name.first}}')">


$scope.getNames = function(name) { // I am getting "{{Name.first}}" which I sent. I am not getting the template value
method : "POST",
url : "/some/url",
params: { value: id },
headers: {
'Content-type': 'application/json'
}).then(function mySucces(response) {
$scope.Results =;

Please tell me how to use template value while calling the method ?

Answer Source

Pass scope variable value without interpolation ({{}}) while calling function from ng-click directive.

<li data-id="{{Name.first}}" ng-click="getNames(Name.first)">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download