This is my code with ui rooter but I want to delete uirooter for
ngComponentRooter in angularJs 1.5
(function () {
'use strict';
angular
.module('app', ['ui.router', 'ngMessages', 'ngStorage', 'ngMockE2E'])
.config(config)
.run(run);
function config($stateProvider, $urlRouterProvider) {
// default route
$urlRouterProvider.otherwise("/");
// app routes
$stateProvider
.state('home', {
url: '/',
templateUrl: 'home/index.view.html',
controller: 'Home.IndexController',
controllerAs: 'vm'
})
.state('login', {
url: '/login',
templateUrl: 'login/index.view.html',
controller: 'Login.IndexController',
controllerAs: 'vm'
});
}
function run($rootScope, $http, $location, $localStorage) {
// keep user logged in after page refresh
if ($localStorage.currentUser) {
$http.defaults.headers.common.Authorization = 'Bearer ' +
$localStorage.currentUser.token;
}
// redirect to login page if not logged in and trying to access a
restricted page
$rootScope.$on('$locationChangeStart', function (event, next,
current) {
var publicPages = ['/login'];
var restrictedPage = publicPages.indexOf($location.path()) ===
-1;
if (restrictedPage && !$localStorage.currentUser) {
$location.path('/login');
}
});
}
})();
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.