Routing documentation

I’m not sure if I’m missing something, but the documentation is extremely poor when it comes to dealing with paramters, childrouters, and overall navigation lifecycle like determining if you can leave and go to a new page. I’m searching for this info too much as I seem to forget more than I can retain as I get older :frowning:

2 Likes

Good Lord, I thought I was the only one! :laughing:
Can you pass me the red crayon… :yum:

2 Likes

Nope, and I’m bouncing between languages too much which makes things extra tough

1 Like

Some TypeScript cheaters that may help.

import { View } from "aurelia-templating";
import * as LogManager from 'aurelia-logging';
import { Logger } from 'aurelia-logging';
import { NavigationInstruction, RouteConfig } from 'aurelia-router';

export interface IComponent {
    attached();
    detached();
    unbind();
    created(owningView: View, myView: View);
    bind(bindingContext: Object, overrideContext: Object);
}


export interface IRoutable {
    canActivate(params: any, routeConfig: RouteConfig, navigationInstruction: NavigationInstruction): void | Promise<any> | NavigationInstruction;
    activate(params: any, routeConfig: RouteConfig, navigationInstruction: NavigationInstruction): void | Promise<any>;
    canDeactivate(): void | Promise<any> | NavigationInstruction;
    deactivate(): void | Promise<any>;
}



export class Component implements IComponent {
    unbind() {
        this.log.debug('Unbind');
    }

    created(owningView: View, myView: View) {
        this.log.debug(`Created view`);
    }

    bind(bindingContext: Object, overrideContext: Object) {
        this.log.debug('Bind');
    }

    log: Logger;
    constructor() {
        this.log = LogManager.getLogger("ComponentLog");
    }
    attached() {
        this.log.debug('Attached');
    }

    detached() {
        this.log.debug('Detached');
    }
}
4 Likes

The Aurelia CLI now ships with a routing example skeleton including a child route setup. Create a new project and choose for custom setup and go for the router feature. This should help a bit.

1 Like