angular.js - angularjs ng-repeat cannot be refreshed
阿神2017-05-15 16:57:36
0
4
608
As shown in the picture, if I push the array directly, the page can be refreshed normally. But if I directly assign a new array to $scope.items, the page will not be refreshed.
The main topic is to transfer the scope of the Controller to the Service. It is better to get the methods of the Service to the Controller. For example:
After assigning the value, console the value of $scope.items to see if you have paid the wrong value... It is difficult to know where your problem is just by writing it like this. Normally it will trigger rendering
Because in js, object assignment is a reference, ng monitoring can be understood as address monitoring, so if the original array remains unchanged, ngrepeat will not be triggered
The answer is in the comments
You are using Angular, use promises:
That’s what I mean, you can add logs or something depending on the situation
The main topic is to transfer the scope of the Controller to the Service. It is better to get the methods of the Service to the Controller.
For example:
After assigning the value, console the value of $scope.items to see if you have paid the wrong value... It is difficult to know where your problem is just by writing it like this. Normally it will trigger rendering
Because in js, object assignment is a reference, ng monitoring can be understood as address monitoring, so if the original array remains unchanged, ngrepeat will not be triggered