【发布时间】:2017-09-15 17:12:52
【问题描述】:
我想知道如何在使用 ng-click 更新后从数据服务器更新视图。
我使用 Daftmonk 均值堆栈生成器。
我用代码打开了另一个主题但没有答案,也许我走错路了update/refresh angularjs ng-repeat with data from server
【问题讨论】:
标签: angularjs node.js mongodb express angularjs-ng-repeat
我想知道如何在使用 ng-click 更新后从数据服务器更新视图。
我使用 Daftmonk 均值堆栈生成器。
我用代码打开了另一个主题但没有答案,也许我走错路了update/refresh angularjs ng-repeat with data from server
【问题讨论】:
标签: angularjs node.js mongodb express angularjs-ng-repeat
查看 $watch 和 $apply
$watch 将监视更改并使用按钮调用 $apply
function MyController($scope) {
$scope.myVar = 1;
$scope.$watch('myVar', function() {
alert('hey, myVar has changed!');
});
$scope.changeValueButton = function() {
$scope.myVar = 2; // This will trigger $watch expression to kick in
};
$scope.updateButton = function() {
$scope.apply();
};
}
【讨论】: