# Router Activation Strategy

**URL:** <https://discourse.aurelia.io/t/router-activation-strategy/964>\
**Category:** Help Requests\
**Created:** [March 24, 2018, 8:19pm UTC](https://discourse.aurelia.io/t/router-activation-strategy/964 "2018-03-24T20:19:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmarchio](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@pmarchio](https://discourse.aurelia.io/u/pmarchio)\
**Post date:** [March 24, 2018, 8:19pm UTC](https://discourse.aurelia.io/t/router-activation-strategy/964/1 "2018-03-24T20:19:59Z")

</div>

I am trying to hook the determineActivationStrategy() callback in any of the routes in the latest esnext skeleton as such in a view model:

import { activationStrategy } from “aurelia-router”;

export class Welcome {

…

```
determineActivationStrategy() {
    console.log("in determineActivationStrategy");
    return activationStrategy.replace;
}

```

}

however, the above function never gets called. I have a similar skeleton where I actually call navugateToRoute on all the routes and the callback will only fire when i navigate to the same View/Model route.

I must be missing something?

---

<div class="post-metadata">

**Author:** ![huochunpeng](https://avatars.discourse-cdn.com/v4/letter/h/49beb7/32.png) [@huochunpeng](https://discourse.aurelia.io/u/huochunpeng)\
**Post date:** [March 25, 2018, 12:07am UTC](https://discourse.aurelia.io/t/router-activation-strategy/964/2 "2018-03-25T00:07:48Z")

</div>

I use exact same code as yours.

~~Can you confirm your `Welcome` class is directly used by a router config `{moduleId: PLATFORM.moduleName('./welcome')}`?~~

Just realize what’s your question.

It’s intend to deal with following routes:

```auto
{route: 'foo/:id', moduleId: PLATFORM.moduleName('./foo')}

```

When you navigate from route `'foo/1'` to `'foo/2'`, the default behaviour is to reuse `'foo'` component, only calls deactivate and activate callbaks.  
`activationStrategy.replace` ensures you get a new `'foo'` instance, and all bind/attach/… lifecycle callbacks.

If you navigate from `'foo'` to `'welcome'`, or from `'welcome'` to `'foo'`, that determineActivationStrategy callback is never called on both foo and welcome instances. Since they are two different class, only “replace” is doable strategy.

---

<div class="post-metadata">

**Author:** ![pmarchio](https://avatars.discourse-cdn.com/v4/letter/p/48db29/32.png) [@pmarchio](https://discourse.aurelia.io/u/pmarchio)\
**Post date:** [March 25, 2018, 1:12pm UTC](https://discourse.aurelia.io/t/router-activation-strategy/964/3 "2018-03-25T13:12:14Z")

</div>

Thanks for this clarification huochunpeng, very much appreciated!
