I have a basic angular block that looks like this
<script>
function simpleList($scope){
$scope.addItem = function(){
$scope.items.push($scope.newItem);
}
$scope.items = ["apple", "orange"];
}
</script>
<div ng-controller="simpleList">
<h3>Items to Add:</h3>
<input type="text" ng-model="newItem"> <button ng-click="addItem()">Add item</button>
<ul>
<li ng-repeat="item in items"><a href="">{{item}}</a></li>
</ul>
{{items}}
</div>
The issue:
- When you click the button, only 1 item is added to the list
- However, if you check the array contents with {{items}}, all values are present
What could be causing this?