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

Commit ad3fbad

Browse files
chalinFoxandxss
authored andcommitted
examples(toh-5, toh-6): fix Dart e2e (#2846)
1 parent b64ec82 commit ad3fbad

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

public/docs/_examples/toh-5/dart/lib/dashboard_component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h3>Top Heroes</h3>
33
<div class="grid grid-pad">
44
<!-- #docregion click -->
5-
<a *ngFor="let hero of heroes" [routerLink]="['./HeroDetail', {id: hero.id}]" class="col-1-4">
5+
<a *ngFor="let hero of heroes" [routerLink]="['HeroDetail', {id: hero.id.toString()}]" class="col-1-4">
66
<!-- #enddocregion click -->
77
<div class="module hero">
88
<h4>{{hero.name}}</h4>

public/docs/_examples/toh-5/dart/lib/hero_detail_component.dart

+3-5
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,13 @@ class HeroDetailComponent implements OnInit {
3737

3838
// #docregion ngOnInit
3939
Future<Null> ngOnInit() async {
40-
var idString = _routeParams.get('id');
41-
var id = int.parse(idString ?? '', onError: (_) => null);
40+
var _id = _routeParams.get('id');
41+
var id = int.parse(_id ?? '', onError: (_) => null);
4242
if (id != null) hero = await (_heroService.getHero(id));
4343
}
4444
// #enddocregion ngOnInit
4545

4646
// #docregion goBack
47-
void goBack() {
48-
_location.back();
49-
}
47+
void goBack() => _location.back();
5048
// #enddocregion goBack
5149
}

public/docs/_examples/toh-6/dart/lib/dashboard_component.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import 'hero_search_component.dart';
1313
selector: 'my-dashboard',
1414
templateUrl: 'dashboard_component.html',
1515
styleUrls: const ['dashboard_component.css'],
16-
directives: const [HeroSearchComponent])
16+
directives: const [HeroSearchComponent, ROUTER_DIRECTIVES])
1717
// #enddocregion search
1818
class DashboardComponent implements OnInit {
1919
List<Hero> heroes;

public/docs/_examples/toh-6/dart/lib/dashboard_component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- #docregion -->
22
<h3>Top Heroes</h3>
33
<div class="grid grid-pad">
4-
<a *ngFor="let hero of heroes" [routerLink]="['/detail', hero.id]" class="col-1-4">
4+
<a *ngFor="let hero of heroes" [routerLink]="['HeroDetail', {id: hero.id.toString()}]" class="col-1-4">
55
<div class="module hero">
66
<h4>{{hero.name}}</h4>
77
</div>

public/docs/_examples/toh-6/dart/lib/hero_detail_component.dart

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// #docplaster
22
// #docregion , v2
33
import 'dart:async';
4-
import 'dart:html';
54

65
import 'package:angular2/core.dart';
76
import 'package:angular2/router.dart';
7+
import 'package:angular2/platform/common.dart';
88

99
import 'hero.dart';
1010
import 'hero_service.dart';
@@ -18,12 +18,13 @@ class HeroDetailComponent implements OnInit {
1818
Hero hero;
1919
final HeroService _heroService;
2020
final RouteParams _routeParams;
21+
final Location _location;
2122

22-
HeroDetailComponent(this._heroService, this._routeParams);
23+
HeroDetailComponent(this._heroService, this._routeParams, this._location);
2324

2425
Future<Null> ngOnInit() async {
25-
var idString = _routeParams.get('id');
26-
var id = int.parse(idString, onError: (_) => null);
26+
var _id = _routeParams.get('id');
27+
var id = int.parse(_id ?? '', onError: (_) => null);
2728
if (id != null) hero = await (_heroService.getHero(id));
2829
}
2930

@@ -34,7 +35,5 @@ class HeroDetailComponent implements OnInit {
3435
}
3536
// #enddocregion save
3637

37-
void goBack() {
38-
window.history.back();
39-
}
38+
void goBack() => _location.back();
4039
}

0 commit comments

Comments
 (0)