I've just started using the new version of Laravel angular. I'm trying to add some code to change a rootScope variable when scrolling down the page. this is what i have so far.
$onInit(){
this.$rootScope.showTestBanner = true;
var $rootScope = this.$rootScope;
angular.element(this.$window).bind("scroll", function() {
if (this.pageYOffset >= 20) {
this.$rootScope.showTestBanner = false;
}
});
}
The problem is that this.$rootScope is undefined inside the angular.element. Ive tried assigning this.$rootScope outside angular.element so it can be used inside the bind function but then the databinding does seem to work. Any suggestions would be much appreciated. If the answer is obvious please excuse me i'm very new to angular 1.5 and ECMA6.