I am facing an issue with my ng-repeat function as it is returning "uncaught illegal access" when I try to add new items to it from the controller.
Although the controller scope array I am using to populate the ng-repeat is being updated correctly, something seems to be going wrong during the process.
This is how my HTML looks:
<div ng-repeat="item in items" class="list-item"
ng-include="'queue/' + item.type.parent + '.html'"></div>
Here's the controller function that is pushing new data to it:
public addNotification(type: string): void {
switch(type) {
case "itemOne":
this.scope.items.unshift(this.service.scope.itemOne);
break;
case "itemTwo":
this.scope.items.unshift(this.service.scope.itemTwo);
break;
case "itemThree":
this.scope.items.unshift(this.service.scope.itemThree);
break;
case "itemFour":
this.scope.items.unshift(this.service.scope.itemFour);
break;
}
// remove item from array after hiding
this.timeout((): void => {
// these properties return illegal access
this.scope.items[0].expand = true;
this.scope.items[0].visible = true;
}, 250);
}
This is how the service Object provides the data:
this.scope.itemOne = {
type: {
parent: 'itemOne'
},
// a bunch of json data
expand: false,
visible: true,
focus: true
};
The controller receives the data properly from the service and the controllers items property has the expected populated list. However, the issue lies with ng-repeat failing to update.
This problem occurs when I attempt to add duplicate json data from the service into the controller. While the controller stores it as expected on this.scope.items, ng-repeat seems to have trouble with duplicates for some reason.
Any assistance would be greatly appreciated!