javascript - How to display value in Input box with AngularJS - Stack Overflow

I just started learning AngularJS. I want to implement a page for editing user info by showing the old

I just started learning AngularJS. I want to implement a page for editing user info by showing the old info in the input field on the page. whenever the user want to update info they can see the old info displayed in the input box and they can change the value which will be stored in ng-model. I used before without ng-model and it works

<input type="text" value="{{event_detail.title}}" class="inputbox form-control">

However it doesn't work with data-ng-model

<input type="text" value="event_detail.title" required id="title" name="title" class="inputbox form-control" data-ng-model="eve.title" placeholder="Title">

is there anyway to solve this problem?

I just started learning AngularJS. I want to implement a page for editing user info by showing the old info in the input field on the page. whenever the user want to update info they can see the old info displayed in the input box and they can change the value which will be stored in ng-model. I used before without ng-model and it works

<input type="text" value="{{event_detail.title}}" class="inputbox form-control">

However it doesn't work with data-ng-model

<input type="text" value="event_detail.title" required id="title" name="title" class="inputbox form-control" data-ng-model="eve.title" placeholder="Title">

is there anyway to solve this problem?

Share Improve this question asked Aug 1, 2014 at 17:52 FizzzzFizzzz 371 gold badge1 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 1

you dont need value

<input type="text" ng-model="event_detail.title" class="inputbox form-control">

OR

<input type="text" ng-model="event_detail.title" required name="title" 
     class="inputbox form-control" placeholder="Title">

In the first example you use event_detail.title. In the bottom example it is eve.title. Please make sure that the variable you use actually exists. Also, if you use ng-value, you shouldn't use the tag's value attribute.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744984328a4604521.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信