Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
42
rated 0 times [  43] [ 1]  / answers: 1 / hits: 38038  / 10 Years ago, fri, april 25, 2014, 12:00:00

Hi I have following issue which seems easy and should work but is not.



In my code I have input



 <input type=text  ng-model=c.Id  ng-init=c.Id={{pId}}/>


When I look at the DOM using firebug tool I see the value



 <input type=text  ng-model=c.Id  ng-init=c.Id=6/>


But it wont display 6 in the input box neither I can access it using #scope.
Please let me know what is wrong here and how to fix it so that ng-model can have from ng-init.
Thanks


More From » jquery

 Answers
12

Get rid of the braces in the expression so that it will evaluate pId directly from the scope



<input type=text  ng-model=c.Id  ng-init=c.Id=pId/>


Plunk


[#71296] Thursday, April 24, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adilene

Total Points: 395
Total Questions: 88
Total Answers: 109

Location: Indonesia
Member since Tue, Aug 3, 2021
3 Years ago
;