• Toby StewardToby Steward, over 6 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
  • Wouter De LooseWouter De Loose, over 6 years ago (edited over 6 years ago )

    In large Angular.js projects, it's much easier to organise your routes in a good directory structure

    For example:

    - routes - Templates // A separate folder that contains parent templates which other routes will use. - users // List of user (/users) - users.route.js - users.controller.js - user.template.js - user // Individual user (user/:user) - user.route.js - user.controller.js - user.template.js - edit // Edit user (user/:user/edit) - edit.route.js - edit.controller.js - edit.template.js - settings // Settings ( /settings) - settings.route.js - settings.controller.js - settings.template.js - notifications // Notifications settings ( /settings/notifications) - notifications.route.js - notifications.controller.js - notifications.template.js

    And so on, if you are looking for user/:user/edit, you instantly know where to look based on the folder directory.

    I've been using this method for a while now in some large Angular.js projects, and found it to be really helpful.

    0 points
    • Dominik Schmidt, over 6 years ago

      So, with the method I mentioned in the article, it's mostly up to you how you structure your directories, just wanted to show how it could look like.

      0 points