Reputation: 11
I have a URL: http://app/material/id/58
I want to get the id '58' on another widget but I am not able to splice the value.
Any suggestions?
Upvotes: 1
Views: 34
Reputation: 2681
Dojo 2 Widgets can then be configured with these outlet identifiers using the Outlet higher order component. Outlet returns a new widget that can be used like any other widget within a render method, e.g. w(MyFooOutlet, { })
Map Parameters:
When a widget is configured for an outlet it is possible to provide a callback function that is used to inject properties that will be available during render lifecycle of the widget.
mapParams(type: 'error | index | main', location: string, params: {[key: string]: any}, router: Router)
The following example uses mapParams to inject an onClose function that will go to the route registered against the other-outlet route and id property extracted from params in the MyViewWidget properties:
const mapParams = (options: MapParamsOptions) {
const { type, params, router } = options;
return {
onClose() {
// This creates a link for another outlet and sets the path
router.setPath(router.link('other-outlet'));
},
id: params.id
}
}
const FooOutlet = Outlet(MyViewWidget, 'foo', { mapParams });
Upvotes: 0