【发布时间】:2017-10-26 07:04:09
【问题描述】:
我在我的应用程序中执行以下代码,有时 ng-init 不会触发 $watch。有什么想法吗?
HTML
<div ng-controller="MyCtrl">
<p ng-init="stages = 'coco'">{{x}}</p>
</div>
控制器
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.$watch("stages", function() {
alert($scope.stages);
});
}
【问题讨论】:
标签: javascript angularjs watch ng-init