abonnieren Sie die Navigation des Routers „Erfolg“ Ereignis:
import {EventAggregator} from 'aurelia-event-aggregator';
import {inject} from 'aurelia-dependency-injection';
@inject(EventAggregator)
export class App {
constructor(eventAggregator) {
this.eventAggregator = eventAggregator;
}
navigationSuccess(event) {
let instruction = event.instruction;
// todo: do something with instruction...
}
attached() {
this.subscription = this.eventAggregator.subscribe(
'router:navigation:success',
this.navigationSuccess.bind(this));
}
detached() {
this.subscription.dispose();
}
}
Hier ist eine etwas andere Version ES7 Funktion Bindung und ES6 Destrukturierung mit:
import {EventAggregator} from 'aurelia-event-aggregator';
import {inject} from 'aurelia-dependency-injection';
@inject(EventAggregator)
export class App {
constructor(eventAggregator) {
this.eventAggregator = eventAggregator;
}
navigationSuccess({ instruction }) {
// todo: do something with instruction...
}
attached() {
this.subscription = this.eventAggregator.subscribe(
'router:navigation:success',
::this.navigationSuccess);
}
detached() {
this.subscription.dispose();
}
}
gute Sachen für die von uns manuell nav Aufbau - Danke – mujimu