aurelia / router

A powerful client-side router.
MIT License
120 stars 115 forks source link

Parent Router doesn't know Id of child #670

Open DanieleRosada opened 3 years ago

DanieleRosada commented 3 years ago

Good morning, I am using powerful routing, to rebuild the status after refreshing the page. But I can't access the parameter :IdRiferimento from the father and therefore I don't know if I have to set the default value or load the previous route.

How can i build the infrastructure to this fairly common problem? Thanks

@autoinject()
export class Riferimenti {

    columns: Array<ColDef> = [
        { headerName: this.localizer.t('assistenza:riferimenti.codice'), field: 'Codice' },
        { headerName: this.localizer.t('assistenza:riferimenti.nominativo'), field: 'Nominativo' },
        { headerName: this.localizer.t('assistenza:riferimenti.privacy'), field: 'Privacy', valueFormatter: (params) => AgGridValueFormatter.Boolean(params, this.localizer) }
    ];

    constructor(@newInstance(RiferimentiState) private state: RiferimentiState, private router: Router, private localizer: XLocale) { }

    configureRouter(config: RouterConfiguration, router: Router) {
        this.router = router;
        config.title = 'Riferimenti';

        config.map([
            { route: '', name: 'nessun-riferimento', moduleId: PLATFORM.moduleName('assistenza/utilities/no-selected') },
            { route: ':IdRiferimento', name: 'riferimento', moduleId: PLATFORM.moduleName('./route/riferimento') }
        ]);
    }

    async activate(params: ParamsRouting) {
        this.state.deselectAll();
        await this.state.getData(params.IdImpianto);

        console.error("riferimenti::", this.state.riferimenti);
    }
}