1

I am new to AngularJS, and I am creating an app, where I have to edit a text. I have created the button. But, I need some help to set up the edit button. When the user clicks on the edit button, I want them to edit the text.

Here is my edit button

<a class="back" href="#/people">Back</a>

   <td><button class="btn btn-primary" ng-click="enableEditor()">Edit</button>
</td>

 <div class="people-view">
 <h2 class="name">{{people.name}}</h2>
 <span class="title">{{people.title}}</span>
 <span class="date">{{people.date}} </span>



  </div>
0

1 Answer 1

3

maintain a variable edit which you can make true on-clicking edit button depending on that variable toggle the text and input

 <a class="back" href="#/lawyer">Back</a>

       <td><button class="btn btn-primary" ng-click="edit=ture">Edit</button>
    </td>

     <div class="people-view">
     <h2 class="name"><span ng-show="!edit">{{people.name}}</span><input ng-show="edit" value="{{people.name}}"></h2>
     <span class="title"><span ng-show="!edit">{{people.title}}<input ng-show="edit" value="{{people.title}}"></span></span>
     <span class="date"><span ng-show="!edit">{{people.date}} <input ng-show="edit" value="{{people.date}}"></span></span>



      </div>

Working demo

Sign up to request clarification or add additional context in comments.

3 Comments

wait i'll create a fiddle demo
@John give ng-model to inputs and put one submit button on submit of this button call a function, get the model values there
can you please show me in the code for the update button?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.