Web tutorials often complicate angularJS conditional routings with strange and complex logic...
I'm looking for something simpler:
Just one component to check if localStorage has authFlag set to true, and then do something like this:
app.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/app.html',
controller: 'AppCtrl'
})
.when('/articles', {
templateUrl: 'views/articles.html',
controller: 'ArticlesCtrl',
conditions: { isAuth }
})
.otherwise({
redirectTo: '/'
});
});
What is the best way to achieve this? Checking if authFlag is in localStorage, and if not, redirect to '/'?