I'm having some problems with emptying my input fields after they have been added with ng-repeat.
My controller looks like this:
var SimpleController = function ($scope) {
$scope.rows = [{id: 'row1' }, {id: 'row2'}, {id: 'row3'}, {id: 'row4'}];
$scope.addText = function () {
$scope.modelRow = "text";
}
$scope.removeText = function () {
$scope.modelRow = " ";
}
}
I'm using ng-repeat on the rows array to add the amount of input fields i need. For example I have function that extends the array if the user need more fields.
Then i have a function to empty the inputs and one to fill them, which works like intended. However, if you type something in the input fields yourself, then neither of the functions won't work on that input.
My HTML:
<div ng-repeat="row in rows" >
<input ng-model="modelRow" type="text" name="text" />
</div>
<button ng-click="addText()">Add text</button>
<button ng-click="removeText()">Remove Text</button>
I'm pretty new to Angular, so i'm probably missing something. Hopefully someone can help me out.
Also made a jsfiddle to demonstrate my problem, which can be found here: jsfiddle (Try typing something and you will see that the functions doesn't work).