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> <h3>Top Heroes</h3>
<div class="grid grid-pad"> <div class="grid grid-pad">
<!-- #docregion click --> <!-- #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 --> <!-- #enddocregion click -->
<div class="module hero"> <div class="module hero">
<h4>{{hero.name}}</h4> <h4>{{hero.name}}</h4>

View File

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

View File

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

View File

@ -1,7 +1,7 @@
<!-- #docregion --> <!-- #docregion -->
<h3>Top Heroes</h3> <h3>Top Heroes</h3>
<div class="grid grid-pad"> <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"> <div class="module hero">
<h4>{{hero.name}}</h4> <h4>{{hero.name}}</h4>
</div> </div>

View File

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