1 year ago
#388588
simon
how to load service on window load in angularjs
I have a service that should load on page refresh how to load this service on window load.
modules.ts
import { _someService, _cmOffService, MenuController } from './some.directive';
const menuModule = angular.module('menuModule', [])
.factory('someService', _someService)
.factory('cmOffService', _cmOffService)
.controller('MenuController', MenuController);
directive.ts
_cmOffService.$inject = ["canvasMenu", "$rootScope"];
alert("outside function") //It does alert
export function _cmOffService(canvasMenu, $rootScope) {
alert("calling this") //Does not work
$rootScope.$on(TOGGLE_OFF, someFunction);
return {
someFunction: someFunction,
};
}
Please guide
Thanks
angularjs
0 Answers
Your Answer