0

What I am trying is to expand the button when button is clicked..At the same time when u want to delete the textbox I am unable identify the process.The first appending of text boxes had been done in the below fiddle.can anyone solve for delete operation

http://plnkr.co/edit/pI9BSWVLYxiSK2bbKuJW?p=preview

to add text boxes

// 
$scope.addContact = function() {
    $scope.contacts.push({
    })
  }

1 Answer 1

2

HTML

<li ng-repeat="contact in contacts track by $index">
  <input type="text" /><button ng-click="removeContact($index)">-</button>   
</li>

Notice I have added a removeContact() method to the button and this is the method:

$scope.removeContact = function(index) {
    $scope.contacts.splice(index, 1);
}

Here is the plnkr

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

5 Comments

Can we give specific id to the appending textboxes ?
@MamataYadav - sure you could use $index to do this like so : <input id="input_{{$index}}" type="text" />. The inputs will have unique id's starting with "input_0", "input_1", etc.
Sorry for asking it agian .These appending of textboxes are done in the popup.I struck in a problem that when i enter anythnng in the textboxes that must me added to the parent view as a label with a textbox again..If anyone does not understant this ask me I would explain it in another way.
I am not sure I understand correctly, but if you trying to "send" the data from the popup to the parent view, and the popup and the parent view do not share the same Controller, you should use a service to pass the data between the popup and the parent view.
suppose i have a controller which displays but the code to write to display it is I am not getting because as i have number of textboxes and its id's .how to assign to a variable one by one and how to display it to the parent view

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.