Also update dart_to_js_script_rewriter dependency to ^1.0.1, and change most angular2.dart imports to be core.dart instead. The pipes example broke without the angular2.dart import, so I let it be. The server-communication sample has never worked for me, so I changed it but might have broken it further. closes #1007
28 lines
579 B
Dart
28 lines
579 B
Dart
// #docplaster
|
|
|
|
// #docregion
|
|
import 'dart:async';
|
|
|
|
import 'package:angular2/core.dart';
|
|
|
|
import 'hero.dart';
|
|
import 'mock_heroes.dart';
|
|
|
|
@Injectable()
|
|
class HeroService {
|
|
Future<List<Hero>> getHeroes() async => HEROES;
|
|
|
|
// See the "Take it slow" appendix
|
|
Future<List<Hero>> getHeroesSlowly() {
|
|
return new Future<List<Hero>>.delayed(
|
|
const Duration(seconds: 2), () => HEROES // 2 seconds
|
|
);
|
|
}
|
|
|
|
//#docregion get-hero
|
|
Future<Hero> getHero(int id) async =>
|
|
HEROES.where((hero) => hero.id == id).first;
|
|
//#enddocregion get-hero
|
|
}
|
|
// #enddocregion
|