Transition plans
Learn how Router handles the re-entrance of the same component and how to override the default behavior.
How does it work
Transition plans are inherited
import { customElement } from '@aurelia/runtime-html';
import { IRouteViewModel, route } from '@aurelia/router';
@customElement({ name: 'ce-one', template: 'ce1 ${id1} ${id2}' })
class CeOne implements IRouteViewModel {
private static id1: number = 0;
private static id2: number = 0;
// Every instance gets a new id.
private readonly id1: number = ++CeOne.id1;
private id2: number;
public canLoad(): boolean {
// Every time the lifecycle hook is called, a new id is generated.
this.id2 = ++CeOne.id2;
return true;
}
}
@route({
transitionPlan: 'replace',
routes: [
{
id: 'ce1',
path: ['', 'ce1', 'ce1/:id'],
component: CeOne,
},
],
})
@customElement({
name: 'my-app',
template: `<a load="ce1">ce-one</a> <a load="ce1/1">ce-one/1</a><br><au-viewport></au-viewport>`,
})
export class MyApp {}Use a function to dynamically select transition plan
Last updated
Was this helpful?