search

Home  >  Q&A  >  body text

angular.js - After loading data using angular, clicking the button to add data cannot directly display the loaded data?

I use angularjs $http to load some data. The data is displayed in pages, and then slides to load the next page, and then clicks the button to add data. There are some problems.
Assume that there are 10 pieces of data on one page. If the current page already has The data is less than 10, the data I added will be displayed directly, using

$scope.count = 1;
$scope.programs.unshift(data.content);

The array is added to the top
If the current data is greater than 10 items, the data I added cannot be displayed directly on the list, and some ng-click elements need to be clicked to display it

Note: There is a lot of code, so I won’t write it down. The main thing is to insert data at the top of all comments. When the data is larger than 1 page, it cannot be directly displayed after adding that a piece of data has been inserted. When it is smaller than one page, it will not be displayed. Problem, how to solve it? ? ?

滿天的星座滿天的星座2792 days ago619

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-15 16:57:48

    I solved it myself, just add $scope.$digest(); and it’s OK

    reply
    0
  • Cancelreply