I'm very new to both angular and MVC programming so im not sure if im doing this correctly.
I have a jquery snippet I wanna use one some of my partials both not all of them. But since the event listeners never expire due the page never reloading I was wondering how I would register my events, listen to them and destroy them the angular way sort of speak.
I read somewhere you should use $scope.on but I don't really understand how it works.
Example
app.controller('PageCtrl', function ($scope, $location, $http) {
// jQuery to collapse the navbar on scroll
$(window).on( "scroll", function() {
if ($(".navbar").offset().top > 50) {
$(".navbar-fixed-top").addClass("top-nav-collapse");
$(".logotype-white").addClass("logotype-hide");
$(".logotype-grey").removeClass("logotype-hide");
} else {
$(".navbar-fixed-top").removeClass("top-nav-collapse");
$(".logotype-white").removeClass("logotype-hide");
$(".logotype-grey").addClass("logotype-hide");
}
});
app.controller('OtherCtrl', function (/* $scope, $location, $http */) {
$(function() {
$(".navbar-fixed-top").addClass("top-nav-collapse");
$(".logotype-white").addClass("logotype-hide");
$(".logotype-grey").removeClass("logotype-hide");
});
A friend of mine suggested I should use namespaces and just unbind all my events but that's not the angular way I guess?