You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/article/en-US/cheat-sheet.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1113,14 +1113,11 @@ Add [a base tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base)
1113
1113
> Warning
1114
1114
> PushState requires server-side support. Don't forget to configure your server appropriately.
1115
1115
1116
-
### Reusing an existing VM
1116
+
### Reusing an Existing View Model
1117
1117
1118
-
Since the VM's navigation life-cycle is called only once you may have problems recognizing that the user switched the route from `Product A` to `Product B` (see below). To work around this issue implement the method `determineActivationStrategy` in your VM and return hints for the router about what you'd like to happen.
1118
+
Since the view model's navigation lifecycle is called only once, you may have problems recognizing that the user switched the route from `Product A` to `Product B` (see below). To work around this issue implement the method `determineActivationStrategy` in your view model and return hints for the router about what you'd like to happen. Available return values are `replace` and `invoke-lifecycle`. Remember, "lifecycle" refers to the navigation lifecycle.
1119
1119
1120
-
> Info
1121
-
> Additionally, you can add an `activationStrategy` property to your route config if the strategy is always the same and you don't want that to be in your view-model code. Available values are `replace` and `invoke-lifecycle`. Remember, "lifecycle" refers to the navigation lifecycle.
1122
-
1123
-
<code-listingheading="Router VM Activation Control">
1120
+
<code-listingheading="Router View Model Activation Control">
1124
1121
<source-codelang="ES 2015/2016">
1125
1122
//app.js
1126
1123
@@ -1139,7 +1136,7 @@ Since the VM's navigation life-cycle is called only once you may have problems r
1139
1136
import {activationStrategy} from 'aurelia-router';
1140
1137
1141
1138
export class Product {
1142
-
determineActivationStrategy(){
1139
+
determineActivationStrategy(){
1143
1140
return activationStrategy.replace;
1144
1141
}
1145
1142
}
@@ -1161,16 +1158,19 @@ Since the VM's navigation life-cycle is called only once you may have problems r
1161
1158
1162
1159
//product.ts
1163
1160
1164
-
import {activationStrategy} from 'aurelia-router';
1161
+
import {activationStrategy, RoutableComponentDetermineActivationStrategy} from 'aurelia-router';
1165
1162
1166
-
export class Product {
1167
-
determineActivationStrategy(): string {
1163
+
export class Product implements RoutableComponentDetermineActivationStrategy {
1164
+
determineActivationStrategy() {
1168
1165
return activationStrategy.replace;
1169
1166
}
1170
1167
}
1171
1168
</source-code>
1172
1169
</code-listing>
1173
1170
1171
+
> Info
1172
+
> Alternatively, if the strategy is always the same and you don't want that to be in your view model code, you can add the `activationStrategy` property to your route config instead.
0 commit comments