I created a simple div that contains overlay with "loading" gif.
I want to be able to show/hide this "loader" and have it accessible through any controller.
I believe I need to use a service for that. this is my simple code which fail to work:
MyApp.factory('loader', function() {
$(".loader").fadeIn();
});
and then in controllers.js:
MyApp.controller('MyController', function($scope, $rootScope, $auth, $state) {
$rootScope.loader;
});
But this does nothing. I'm new to angular and I'd appreciate a direction to solve this.
I essentially want to create something like this:
loader.show();
loader.hide();
Of course if anyone think this should be done differently it would be great to hear a more efficient way.