Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit a83261a

Browse files
docs(router): Added transition aliases for route animations
1 parent b50927a commit a83261a

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

public/docs/_examples/router/e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('Router', function () {
114114
return page.loginButton.click();
115115
}).then(function() {
116116
expect(page.adminPreloadList.count()).toBe(1, 'should be 1 preloaded module');
117-
expect(page.adminPreloadList.first().getText()).toBe('Crisis Center', 'first preload should be crisis center');
117+
expect(page.adminPreloadList.first().getText()).toBe('crisis-center', 'first preload should be crisis center');
118118
});
119119
});
120120

public/docs/_examples/router/ts/app/app-routing.module.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import { PreloadSelectedModules } from './selective-preload-strategy';
2525
path: 'crisis-center',
2626
loadChildren: 'app/crisis-center/crisis-center.module#CrisisCenterModule',
2727
data: {
28-
moduleName: 'Crisis Center',
2928
preload: true
3029
}
3130
}

public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.1.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ import { DialogService } from '../dialog.service';
3535
transform: 'translateX(0)'
3636
})
3737
),
38-
transition('void => *', [
38+
transition(':enter', [
3939
style({
4040
opacity: 0,
4141
transform: 'translateX(-100%)'
4242
}),
4343
animate('0.2s ease-in')
4444
]),
45-
transition('* => void', [
45+
transition(':leave', [
4646
animate('0.5s ease-out', style({
4747
opacity: 0,
4848
transform: 'translateY(100%)'

public/docs/_examples/router/ts/app/crisis-center/crisis-detail.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ import { DialogService } from '../dialog.service';
3434
transform: 'translateX(0)'
3535
})
3636
),
37-
transition('void => *', [
37+
transition(':enter', [
3838
style({
3939
opacity: 0,
4040
transform: 'translateX(-100%)'
4141
}),
4242
animate('0.2s ease-in')
4343
]),
44-
transition('* => void', [
44+
transition(':leave', [
4545
animate('0.5s ease-out', style({
4646
opacity: 0,
4747
transform: 'translateY(100%)'

public/docs/_examples/router/ts/app/heroes/hero-detail.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ import { Hero, HeroService } from './hero.service';
3434
transform: 'translateX(0)'
3535
})
3636
),
37-
transition('void => *', [
37+
transition(':enter', [
3838
style({
3939
opacity: 0,
4040
transform: 'translateX(-100%)'
4141
}),
4242
animate('0.2s ease-in')
4343
]),
44-
transition('* => void', [
44+
transition(':leave', [
4545
animate('0.5s ease-out', style({
4646
opacity: 0,
4747
transform: 'translateY(100%)'

public/docs/_examples/router/ts/app/selective-preload-strategy.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ export class PreloadSelectedModules implements PreloadingStrategy {
1010

1111
preload(route: Route, load: Function): Observable<any> {
1212
if (route.data && route.data['preload']) {
13-
// add the "moduleName" to our preloaded module array
14-
this.preloadedModules.push(route.data['moduleName']);
13+
// add the route path to our preloaded module array
14+
this.preloadedModules.push(route.path);
15+
16+
// log the route path to the console
17+
console.log('Preloaded: ' + route.path);
1518

1619
return load();
1720
} else {

public/docs/ts/latest/guide/router.jade

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,8 +1142,8 @@ h3#route-animation Adding animations to the route component
11421142
:marked
11431143
Next, we'll use a **host binding** for route animations named *@routeAnimation*. There is nothing special
11441144
about the choice of the binding name, but since we are controlling route animation, we'll go with `routeAnimation`.
1145-
The binding value is set to `true` because we only care about the `*` and `void` states which are
1146-
[entering and leaving](../guide/animations.html#example-entering-and-leaving) animation states.
1145+
The binding value is set to `true` because we only care about the `:enter` and `:leave` states which are
1146+
[entering and leaving](../api/core/index/transition-function.html#transition-aliases-enter-and-leave-) transition aliases.
11471147

11481148
We'll also add some display and positioning bindings for styling.
11491149

@@ -1152,8 +1152,8 @@ h3#route-animation Adding animations to the route component
11521152
:marked
11531153
Now we can build our animation trigger, which we'll call *routeAnimation* to match the binding we previously
11541154
setup. We'll use the **wildcard state** that matches any animation state our route component is in, along with
1155-
two *transitions*. One transition animates the component as it enters the application view (`void => *`), while the other
1156-
animates the component as it leaves the application view (`* => void`).
1155+
two *transitions*. One transition animates the component as it enters the application view (`:enter`), while the other
1156+
animates the component as it leaves the application view (`:leave`).
11571157

11581158
We could add different transitions to different route components depending on our needs. We'll just animate our `HeroDetailComponent` for this milestone.
11591159

@@ -1905,7 +1905,7 @@ h3#resolve-guard <i>Resolve</i>: pre-fetching component data
19051905

19061906
We need the `Resolve` guard.
19071907

1908-
### Preload route information
1908+
### Fetch data before navigating
19091909

19101910
We'll update our `Crisis Detail` route to resolve our Crisis before loading the route, or if the user happens to
19111911
navigate to an invalid crisis center `:id`, we'll navigate back to our list of existing crises.
@@ -2199,7 +2199,7 @@ h3#preloading <i>Pre-Loading</i>: background loading of feature areas
21992199

22002200
<a id="custom-preloading"></a>
22012201
:marked
2202-
### Custom Pre-Loading
2202+
### Custom Pre-Loading Strategy
22032203

22042204
Pre-loading all modules works well in some situations, but in some cases we need more control over what gets loaded eagerly. This becomes more clear
22052205
as we load our application on a mobile device, or a low bandwidth connection. We may only want to preload certain feature modules based on user metrics
@@ -2210,8 +2210,9 @@ h3#preloading <i>Pre-Loading</i>: background loading of feature areas
22102210
Since we want to take advantage of this, we'll add a custom strategy that _only_ preloads the modules we select. We'll enable the preloading by using the *Route Data*,
22112211
which we learned is an object to store arbitrary route data and and [resolve data](#resolve-guard).
22122212

2213-
We'll add a custom `preload` boolean to our `crisis-center` route data that we'll use with our custom strategy. To see it in action, we've added an arbitrary
2214-
`moduleName` property to our route data also that will be added to the `preloadedModules` array in our custom strategy service.
2213+
We'll add a custom `preload` boolean to our `crisis-center` route data that we'll use with our custom strategy. To see it in action, we'll add to
2214+
the `route.path` to the `preloadedModules` array in our custom strategy service. We'll also log a message
2215+
to the console for the preloaded module.
22152216

22162217
+makeExcerpt('app/app-routing.module.ts (route data preload)', 'preload-v2')
22172218

@@ -2236,9 +2237,8 @@ h3#preloading <i>Pre-Loading</i>: background loading of feature areas
22362237
+makeExcerpt('app/admin/admin-dashboard.component.ts (preloaded modules)', '')
22372238

22382239
:marked
2239-
Once our application is loaded to our inital route, the *CrisisCenterModule* is loaded eagerly. We can verify this by logging in to the `Admin` feature area and
2240-
noting that our `Crisis Center` is listed in the `Preloaded Modules.`
2241-
2240+
Once our application is loaded to our initial route, the *CrisisCenterModule* is loaded eagerly. We can verify this by logging in to the `Admin` feature area and
2241+
noting that the `crisis-center` is listed in the `Preloaded Modules` and logged to the console. We can continue to add feature modules to be selectively loaded eagerly.
22422242

22432243

22442244
<a id="final-app"></a>

0 commit comments

Comments
 (0)