javascript - AngularJS run method doesn't always run -
I am writing simple app in angular and I want to know whether the user is logged in or not. If not - then redirect it. It almost works, but when I am at the # / form site, type [anglesite] # / home in my browser, then I get home page every other time, and the second time I am being redirected Why is not the running mode always running? I was also checking with caution - and this is the thing - the warning shows the second time the factory ('$ login check', function () {return function () {// check that the local storage is incorrect if it is returned ;};}); Var myApp = angular.module ('myApp', ['ngRoute', 'myAppControllers', 'Myelogene check']); MyApp.config (['$ routeProvider', '$ locationProvider', function ($ route provider, $ location provider) {$ routeProvider.} ('/ Form', {templateUrl: 'views / form.html', Controller: 'FormCtrl' Otherwise ({redirectTo: '/ form'});}].) Run (function ($ ('/ home', {templateUrl: 'views / home.html', control: 'HomeCtrl'}). Logincheck, $ location } {Warning (2); if ($ login check ()) {} other {$ location.path ('/ form');}});
The run code is for the code that you intend to run once application, every time you put it in a service or controller Land or whatever way you want to run it, is required to run it.
Comments
Post a Comment