Easier organisation of routes in Angular.js(medium.com)

almost 6 years ago from Dominik Schmidt, kreativgebiet.com

  • Toby StewardToby Steward, over 5 years ago

    I noticed that you seem to be repeating a lot of code with your named views - one option would be to use abstract views to provide layouts you can then nest under.


    .state('guest', { abstract: true, templateProvider: function ($templateCache) { return $templateCache.get('/views/templates/guest.html'); }, resolve: { User: function (AuthService) { return AuthService.isGuest(); } } }) .state('guest.login', { url: '/login', controller: 'LoginController as vm', templateProvider: function ($templateCache) { return $templateCache.get('/views/login.html'); } })
    1 point