我是棱角分明的新手,一直在寻找答案,为什么这不起作用.
我的指示在这里:
.directive('carrouselPreview', function () {
return function (scope, element, attrs) {
scope.$watch(scope.carouselPreview, function () {
alert('changed');
}, true);
}
});
Run Code Online (Sandbox Code Playgroud)
这会监视对scope.carouselPreview的更改,该更改通过以下函数进行更改:
$scope.showPreview = function(ind){
$scope.carouselPreview = ind;
}
Run Code Online (Sandbox Code Playgroud)
这个函数肯定会触发并更改scope.carouselPreview - 但是watch函数永远不会触发!
我意识到我可能在这里愚蠢,但我看了一遍,看起来很好.
如果今晚有人帮我解决这个问题,我会永远爱你!