【发布时间】:2015-06-12 13:06:22
【问题描述】:
我在控制器中编写了这段代码:
$('#categoryId').on('click', function(event){
$scope.items = $scope.getUpdatedItems ();
console.log('Items ',$scope.items );
});
在我的指令中我有这个:
....
scope.$watch('items', function(items){
console.log('Directives - Items ',items );
....
问题是我从不输入指令中声明的 $watch。
有人可以帮助我.. 谢谢
【问题讨论】:
-
你试过 $scope.$apply(),因为你在 Angular 上下文之外运行代码
-
为什么不考虑
ng-click? -
@user880386 检查我已经添加了一个答案..使用有效的方法
标签: angularjs angularjs-directive controller scope