ion-route
The route component takes a component and renders it when the Browser URL matches the url property.
Note: this component should only be used with vanilla and Stencil JavaScript projects. For Angular projects, use
ion-router-outlet
and the Angular router.
#
Navigation HooksNavigation hooks can be used to perform tasks or act as navigation guards. Hooks are used by providing functions to the beforeEnter
and beforeLeave
properties on each ion-route
. Returning true
allows navigation to proceed, while returning false
causes it to be cancelled. Returning an object of type NavigationHookOptions
allows you to redirect navigation to another page.
#
Interfaces#
Usage- JAVASCRIPT
- STENCIL
- VUE
#
Properties#
beforeEnterDescription | A navigation hook that is fired when the route tries to enter. Returning true allows the navigation to proceed, while returningfalse causes it to be cancelled. Returning a NavigationHookOptions object causes the router to redirect to the path specified. |
Attribute | undefined |
Type | (() => NavigationHookResult \| Promise<NavigationHookResult>) \| undefined |
Default | undefined |
#
beforeLeaveDescription | A navigation hook that is fired when the route tries to leave. Returning true allows the navigation to proceed, while returningfalse causes it to be cancelled. Returning a NavigationHookOptions object causes the router to redirect to the path specified. |
Attribute | undefined |
Type | (() => NavigationHookResult \| Promise<NavigationHookResult>) \| undefined |
Default | undefined |
#
componentDescription | Name of the component to load/select in the navigation outlet (ion-tabs , ion-nav )when the route matches. The value of this property is not always the tagname of the component to load, in ion-tabs it actually refers to the name of the ion-tab to select. |
Attribute | component |
Type | string |
Default | undefined |
#
componentPropsDescription | A key value { 'red': true, 'blue': 'white'} containing props that should be passedto the defined component when rendered. |
Attribute | undefined |
Type | undefined \| { [key: string]: any; } |
Default | undefined |
#
urlDescription | Relative path that needs to match in order for this route to apply. Accepts paths similar to expressjs so that you can define parameters in the url /foo/:bar where bar would be available in incoming props. |
Attribute | url |
Type | string |
Default | '' |
#
EventsName | Description |
---|---|
ionRouteDataChanged | Used internally by ion-router to know when this route did change. |