Answer the question
In order to leave comments, you need to log in
Why doesn't the $watch in the directive watch the $scope variables?
Hello!
<div ng-controller="ParametersCtrl as ctrl">
<div class="modal-resize" resize-parameters ng-click="ctrl.resize()">Раскрыть</div>
<!--Разметка-->
</div>
this.resize = function() {
$scope.fullScreen = !$scope.fullScreen;
};
define(['app'], function(app) {
app.directive('resizeParameters', function() {
return {
restrict: 'A',
link: function($scope, element, attrs) {
$scope.$watch($scope.fullScreen, function(fullScreen) {
console.log('resize');
})
}
}
})
});
Answer the question
In order to leave comments, you need to log in
It looks like you need to change it like this:
$scope.$watch($scope.fullScreen, function(fullScreen)
$scope.$watch("fullScreen", function(fullScreen)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question