My HTML code is set up to bind the $scope.comments array to an unordered list;
<div ng-app="" ng-controller="commentController">
<ul>
<li ng-repeat="c in comments">
{{ c }}
</li>
</ul>
<div>
After that, I have a script that initializes and allows for the addition of more items to the list;
<script>
function commentController($scope){
$scope.comments = ['Hi There.'];
$scope.addComment = function(){
$scope.comments.push($scope.newcomment);
$scope.newcomment='';
};
};
</script>
Everything works perfectly until I try to add a duplicate item. Upon debugging, I noticed that while Javascript does push the duplicate item to the array, Angular data binding fails to update the list.
Can anyone provide any insight into why this might be happening or point out any mistakes in my approach?