Method that gets executed before the outlet contents is updated with
the new element. The user can prevent the navigation by returning
commands.prevent()
from the method or same value wrapped in Promise
.
If the router navigates to the same path twice in a row, and this results
in rendering the same component name (if the component is created
using component
property in the route object) or the same component instance
(if the component is created and returned inside action
property of the route object),
in the second time the method is not called. In case of navigating to a different path
but within the same route object, e.g. the path has parameter or wildcard,
and this results in rendering the same component instance, the method is called if available.
The WebComponent instance on which the callback has been invoked is available inside the callback through
the this
reference.
Return values:
commands.prevent()
result is returned (immediately or
as a Promise), the navigation is aborted and the outlet contents
is not updated.commands.redirect(path)
result is returned (immediately or
as a Promise), Vaadin Router ends navigation to the current path, and
starts a new navigation cycle to the new path.Arguments:
the RouterLocation
object
the commands object with the following methods:
Property | Description |
---|---|
commands.redirect(path) |
function that creates a redirect data for the path specified, to use as a return |
value from the callback. | |
commands.prevent() |
function that creates a special object that can be returned to abort the current |
navigation and fall back to the last one. If there is no existing one, an exception is thrown. | |
commands.redirectResult(path) |
function that creates a redirect data for the path specified, to use as a return |
value from the callback. | |
commands.prevent() |
function that creates a special object that can be returned to abort the current |
navigation and fall back to the last one. If there is no existing one, an exception is thrown. |
the Router
instance
Web component route interface with onBeforeEnter callback.
Deprecated
Use WebComponentInterface.