Reputation: 1378
I have set a ng-model to a input test in HTML
<input ng-model="nnvalue.temp" ng-change="updateValue(nnvalue.temp)"/>
on the function updateValue(val), i 've written like the following
$scope.updateValue=function(val) {
alert("op is" +val);
}
Output: If i type "s" i am getting the alert message "op is s"
What i need is, i need to get the name of model to be printed in alert (i.e) "op is nnvalue.temp"
Can anyone tell me how to do this
Thanks
Upvotes: 0
Views: 45
Reputation: 86
Change your html to this
<input ng-model="nnvalue.temp" ng-change="updateValue('nnvalue.temp')"/>
The ' ' around the variable name makes it a string, without this it gives the value of that variable
Upvotes: 1