Reusing an Existing View Model
By default, Aurelia creates a new view model instance for each navigation. However, you can control this behavior using the determineActivationStrategy
hook.
Available strategies are:
activationStrategy.replace
: Create a new instance of the view modelactivationStrategy.invokeLifecycle
: Reuse the existing view model, but call the lifecycle hooks
You can also specify the activation strategy in the route config:
This approach is useful when you want to reuse a view model but still refresh its data or state when navigating to it.
Last updated
Was this helpful?