1

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?

    2 Answers 2

    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"> 
    2
    • you can do that with ng-show/hide?? should i update answer with example??
      – harishr
      CommentedAug 1, 2014 at 18:03
    • That is ok.:) I think using two different variable for display and edit is not the best way. I will just use one instead. Thx for help
      – Fizzzz
      CommentedAug 1, 2014 at 18:06
    0

    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.

    2
    • Thx for mention that. What I want is to display event_detail.title which is the old info, and store it into eve.title and submit with it.
      – Fizzzz
      CommentedAug 1, 2014 at 18:00
    • Then you can copy the value of event_detail. Title into eve.title and use that in the ng-model directive. It will display the old value and will automatically update it once the user changes the text.CommentedAug 1, 2014 at 18:10

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.