I try to detect when the user scroll the view and then I would like to switch view.
I'm using a directive for detect when the user scroll :
.directive("scroll", function ($window) {
return function(scope, element, attrs) {
angular.element($window).bind("scroll", function() {
if (this.pageYOffset >= 1) {
scope.boolChangeClass = true;
console.log('Scrolled down');
} else {
scope.boolChangeClass = false;
console.log('Scroll up');
}
scope.$apply();
});
};
The directive is called on the div with the ng-controller
<div scroll ng-controller="MyCtrl1">
I get the boolChangeClass in the view of Controller 1
<span>{{boolChangeClass}}</span>
And log the result in my controller
myApp.controller('MyCtrl1', ['$scope', '$http', function($scope, http) {
console.log($scope.boolChangeClass);
}]);
How can I detect in my controller that boolChangeClass have changed and then I would like to go to controller2 ?