最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论