【发布时间】:2014-06-03 07:08:21
【问题描述】:
我无法重新渲染 ng-repeat。 ng-repeat 连接到一个范围变量,我正在尝试使用 ng-click 进行更改。 ng-click 时变量的值会发生变化,但 ng-repeat 不会重新渲染。我已经尝试过所有关于使用 $scope.$apply 的建议,但我无法实现它。请帮忙。
在此处查看 plunker:http://plnkr.co/edit/iuh6tMrrjkKxCvQABaa5?p=preview
相关代码如下: (一个 ng-click 可以改变 $scope.currentPaginationValue,这在 Batarang 中很明显,但它不会导致重新渲染与 $scope.numbers 关联的 ng-repeat)
.controller('numbersController', function($scope, dataService) {
$scope.currentPaginationValue = 4;
$scope.numbers = dataService.fetchNumbers($scope.currentPaginationValue);
$scope.gotoPrevPage = function() {
$scope.currentPaginationValue = $scope.currentPaginationValue - 1;
};
})
【问题讨论】:
标签: angularjs binding angularjs-scope angularjs-ng-repeat