-2

i have a array of objects in the controller . when the controller invoked,ng-repeat shows all objects in the array as list. works fine.. but when i push a new object first time into the array. works fine.. it shows the object as well. when i push another object into array it doesn't show that object.how to fix this issue? Controller:

 App.controller('teamController', function($scope,$http,$routeParams,$location,$filter) {
$scope.teammembers = [];});

Directive:App.directive("searchableMultiselect", function($timeout) { return { templateUrl: 'angular/templates/team/teamdropdown.php', restrict: 'AE', scope: { displayAttr: '@', allItems: '=', },link: function(scope, element, attrs) {});

**Template:**

    <li ng-repeat="item in ::allItems track by $index">

Frontend:

<searchable-multiselect display-attr="name"
                                        all-items="teammembers" >
                                     </searchable-multiselect>
Karan
  • 75
  • 1
  • 7

1 Answers1

2

you allow only one-way binding. need to change it to two-way binding. remove :: in the ng-repeat

<li ng-repeat="item in allItems track by $index">
Sachila Ranawaka
  • 39,756
  • 7
  • 56
  • 80
  • i want to avoid dublicates in that array.. when i push the object into array it should not be dublicate.. have solution? – Karan Jun 05 '17 at 08:30
  • check this https://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript – Sachila Ranawaka Jun 05 '17 at 08:35