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

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
13 changes: 6 additions & 7 deletions public/docs/_examples/toh-6/dart/lib/hero_detail_component.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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));
}

Expand All @@ -34,7 +35,5 @@ class HeroDetailComponent implements OnInit {
}
// #enddocregion save

void goBack() {
window.history.back();
}
void goBack() => _location.back();
}