javascript - Why toString() is not working in ng-model attribute? -


how use tostring() on ng-model attribute in angularjs

my controller have array variable

like

$scope.usernamelist = ['a','b','c']; 

i want bind array string


i have tried below code working:-

$scope.usernamelist.tostring();//result a,b,c 

but when use tostring() in ng-model attribute, it's not working

<td style="text-align: center"><label ng-model="usernamelist.tostring()"></label></td>// not working 

but if use {{listofrolename.tostring()}}, it's working.

<td style="text-align: center">{{listofrolename.tostring()}}</td>//working 

why tostring() not working in ng-model attribute?

ng-model used two-way databinding , can't reasonably bind result of function call.

if want display result, use ng-bind instead.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -