I have a sample todo app in angularjs. My list of todos is an array. but everytime only the last value of array item is getting added to li's.
I have replicated the issue on a jsbin.
http://jsbin.com/simafuzidi/3/edit
I want the list of todo item to have all the fields that are typed in text boxes and not just the last one. I know this is a closure problem but I am not sure how to solve this in the current circumstances.
thanks
$scope.addTodo = function() {
$scope.todos.push({text:$scope.todoText1,text:$scope.todoText2,text:$scope.todoText3,text:$scope.todoText4,done:false});
$scope.todoText1 = '';
$scope.todoText2 = '';
$scope.todoText3 = '';
$scope.todoText4 = '';
};
<form ng-submit="addTodo()">
<input type="text" ng-model="todoText1" size="30"
placeholder="add new todo here1"><br />
<input type="text" ng-model="todoText2" size="30"
placeholder="add new todo here2"><br />
<input type="text" ng-model="todoText3" size="30"
placeholder="add new todo here3"><br />
<input type="text" ng-model="todoText4" size="30"
placeholder="add new todo here4"><br />
<input class="btn-primary" type="submit" value="add">
</form>