Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Define your application routes as top level routes using JSON files.

License

doktordirk/aurelia-router-loader

 
 

Repository files navigation

Aurelia Router Loader

Author routes in your Aurelia applications using JSON files.

How to use it

Like you would any other plugin. Simply include it and then supply the location of your route files. The following assumes you have a routes folder in your root application directory (one up from src).

export function configure(aurelia) {
    aurelia.use
        .standardConfiguration()
        .developmentLogging()
        .plugin('aurelia-router-loader', config => {
            return config.defineRoutes([
                '/routes/main.json',
                '/routes/admin.json' 
            ]);
        });
        
    aurelia.start().then(a => a.setRoot());
}

Please ensure your router files are in proper JSON format:

[
      { 
          "route": "",         
          "name": "home",        
          "moduleId": "welcome",        
          "nav": true, 
          "title": "Welcome" 
      },
      { 
          "route": "users",         
          "name": "users",        
          "moduleId": "users",        
          "nav": true, 
          "title": "Github Users" 
      },
      { 
          "route": "child-router",  
          "name": "child-router", 
          "moduleId": "child-router", 
          "nav": true, 
          "title": "Child Router" 
      }
]

Instead of configureRouter, we just get the router from the plugin

import { RouterLoader } from 'aurelia-router-loader';

@autoinject()
export class App {
  public router: Router;

  constructor(private routerLoader: RouterLoader) {
    this.router = routerLoader.router;
  }

About

Define your application routes as top level routes using JSON files.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%