2016-03-16 14:39:06 -04:00
|
|
|
// #docplaster
|
|
|
|
// #docregion
|
2016-06-15 07:46:26 -07:00
|
|
|
import 'dart:async';
|
|
|
|
|
2016-03-25 16:03:53 -07:00
|
|
|
import 'package:angular2/core.dart';
|
2016-03-16 14:39:06 -04:00
|
|
|
// #docregion import-router
|
|
|
|
import 'package:angular2/router.dart';
|
|
|
|
// #enddocregion import-router
|
|
|
|
|
|
|
|
import 'hero.dart';
|
|
|
|
import 'hero_service.dart';
|
|
|
|
|
|
|
|
@Component(
|
|
|
|
selector: 'my-dashboard',
|
|
|
|
// #docregion template-url
|
|
|
|
templateUrl: 'dashboard_component.html',
|
|
|
|
// #enddocregion template-url
|
|
|
|
// #docregion css
|
|
|
|
styleUrls: const ['dashboard_component.css']
|
|
|
|
// #enddocregion css
|
2016-06-15 07:46:26 -07:00
|
|
|
)
|
2016-03-16 14:39:06 -04:00
|
|
|
// #docregion component
|
|
|
|
class DashboardComponent implements OnInit {
|
|
|
|
List<Hero> heroes;
|
2016-06-15 07:46:26 -07:00
|
|
|
|
|
|
|
// #docregion ctor
|
2016-03-16 14:39:06 -04:00
|
|
|
final Router _router;
|
|
|
|
final HeroService _heroService;
|
|
|
|
|
|
|
|
DashboardComponent(this._heroService, this._router);
|
|
|
|
|
2016-06-15 07:46:26 -07:00
|
|
|
// #enddocregion ctor
|
|
|
|
|
|
|
|
Future<Null> ngOnInit() async {
|
2016-06-28 13:15:29 -07:00
|
|
|
heroes = (await _heroService.getHeroes()).skip(1).take(4).toList();
|
2016-06-15 07:46:26 -07:00
|
|
|
}
|
2016-03-16 14:39:06 -04:00
|
|
|
|
|
|
|
// #docregion goto-detail
|
2016-06-15 07:46:26 -07:00
|
|
|
void gotoDetail(Hero hero) {
|
2016-03-16 14:39:06 -04:00
|
|
|
var link = [
|
|
|
|
'HeroDetail',
|
|
|
|
{'id': hero.id.toString()}
|
|
|
|
];
|
|
|
|
_router.navigate(link);
|
|
|
|
}
|
|
|
|
// #enddocregion goto-detail
|
|
|
|
}
|