How to update a list inside ng-repeat using angular?


i lave an ionic list

  <ion-item ng-repeat="item in items">
    Hello, {{}}!

then, in the controller i have a event:

$scope.items = someData();
itemsRef.on('event', function (response) {
    console.log(response); // this is an object containing he "name" property

i would like append the response as a ion-item, without inserting html, but somehow adding the response to the items

I’ve tried: $scope.items .push(response); but weirdly enough i get Uncaught TypeError: undefined is not a function

edit: it looks like one doesn’t just $scope.items.push(response);, but $scope.items[next_key_here] = response;



Hi friend,

you should $watch your collection items. I do believe you have a function called in a ng-click, which inserts a new item in your items… so, it would be something like:

$ = someData();

 $scope.addNewItem = function(){

$scope.$watch('data.items', $scope.addNewItem (),true);