i`m using angular 1.4.
i have watchgroup in scope:
$scope.$watchgroup( ["scroll_top", "tokeninput_has_focus"], function(newvalues, oldvalues, scope) { console.log("watch"); } ); and change $scope.scroll_top variable in event:
out of scope function:
restegourmetapp.directive("scroll", function ($window) { return function(scope, element, attrs) { angular.element($window).bind("scroll", function() { scope.$broadcast("onwindowscroll", $window); }); }; }); inside scope function:
$scope.$on('onwindowscroll', function(scope, element, attrs) { $scope.scroll_top = $window.scrolly; console.log("scroll"); }); but watchgroup function not executed, when scroll, console outputs "scroll" not "watch".
i need change
$scope.$on('onwindowscroll', function(scope, element, attrs) { $scope.scroll_top = $window.scrolly; $scope.$apply(); console.log("scroll"); }); to trigger watch function-
i not understand this? thought inside scope $scope.$on.
there must not understand, can me?
thank you!
Comments
Post a Comment