gpt4 book ai didi

javascript - 在 View 和 Controller 之间更新 Angular ng-repeat 数据值的最佳方法是什么?

转载 作者:行者123 更新时间:2023-12-03 10:51:36 25 4
gpt4 key购买 nike

如何在 View 和 Controller 之间更新 ng-repeat 的数据?如果我输入:

ng-repeat="item in actions"

如果我将 Controller 中的 $scope.actions 更改为其他值,它会在 ng-repeat 中更新吗?这是在 View 和 Controller 之间更新 ng-repeat 数据值的最佳方法吗?

最佳答案

ng-repeat 很慢,当你有足够的数据开始研究 ng-repeat 的更好性能时你就会知道。

你的第一个问题

if I change $scope.actions in controller to some other value, would it be updated in ng-repeat?

是的,但是如果它不起作用,请使用 Angular 的“$timeout”

$timeout(function(){
$scope.actions = [];
},0)

你的第二个问题

Is this the best way to update data values for ng-repeat between view and controller?

这是最好的方法,尽管建议补充 ng-repeat limitToInfinite scrolling 一起。

看看at this stack overflow question

关于javascript - 在 View 和 Controller 之间更新 Angular ng-repeat 数据值的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28405639/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com