examples(toh-5, toh-6): fix Dart e2e (#2846)

This commit is contained in:
Patrice Chalin 2016-11-21 04:58:59 -08:00 committed by Jesús Rodríguez
parent b64ec8275a
commit ad3fbada10
5 changed files with 12 additions and 15 deletions

View File

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

View File

@ -37,15 +37,13 @@ class HeroDetailComponent implements OnInit {
// #docregion ngOnInit
Future<Null> ngOnInit() async {
var idString = _routeParams.get('id');
var id = int.parse(idString ?? '', onError: (_) => null);
var _id = _routeParams.get('id');
var id = int.parse(_id ?? '', onError: (_) => null);
if (id != null) hero = await (_heroService.getHero(id));
}
// #enddocregion ngOnInit
// #docregion goBack
void goBack() {
_location.back();
}
void goBack() => _location.back();
// #enddocregion goBack
}

View File

@ -13,7 +13,7 @@ import 'hero_search_component.dart';
selector: 'my-dashboard',
templateUrl: 'dashboard_component.html',
styleUrls: const ['dashboard_component.css'],
directives: const [HeroSearchComponent])
directives: const [HeroSearchComponent, ROUTER_DIRECTIVES])
// #enddocregion search
class DashboardComponent implements OnInit {
List<Hero> heroes;

View File

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

View File

@ -1,10 +1,10 @@
// #docplaster
// #docregion , v2
import 'dart:async';
import 'dart:html';
import 'package:angular2/core.dart';
import 'package:angular2/router.dart';
import 'package:angular2/platform/common.dart';
import 'hero.dart';
import 'hero_service.dart';
@ -18,12 +18,13 @@ class HeroDetailComponent implements OnInit {
Hero hero;
final HeroService _heroService;
final RouteParams _routeParams;
final Location _location;
HeroDetailComponent(this._heroService, this._routeParams);
HeroDetailComponent(this._heroService, this._routeParams, this._location);
Future<Null> ngOnInit() async {
var idString = _routeParams.get('id');
var id = int.parse(idString, onError: (_) => null);
var _id = _routeParams.get('id');
var id = int.parse(_id ?? '', onError: (_) => null);
if (id != null) hero = await (_heroService.getHero(id));
}
@ -34,7 +35,5 @@ class HeroDetailComponent implements OnInit {
}
// #enddocregion save
void goBack() {
window.history.back();
}
void goBack() => _location.back();
}