1
1
// #docplaster
2
-
3
2
// #docregion
4
-
5
3
// #docregion imports
6
4
import 'package:angular2/core.dart' ;
5
+
6
+ import 'app_config.dart' ;
7
7
import 'car/car_component.dart' ;
8
8
import 'heroes/heroes_component.dart' ;
9
- import 'app_config.dart' ;
10
9
import 'logger_service.dart' ;
11
10
import 'user_service.dart' ;
12
-
11
+ //PENDING: check whether we intend to hide injector_component.dart & providers_component.dart; if so, change docregion name?
13
12
// #enddocregion imports
14
13
import 'injector_component.dart' ;
15
14
import 'providers_component.dart' ;
16
15
17
16
@Component (
18
17
selector: 'my-app' ,
19
18
template: '''
20
- <h1>{{title}}</h1>
21
- <my-car></my-car>
22
- <my-injectors></my-injectors>
23
- <my-tests></my-tests>
24
- <h2>User</h2>
25
- <p id="user">
26
- {{userInfo}}
27
- <button (click)=\' nextUser()\' >Next User</button>
28
- <p>
29
- <my-heroes id="authorized" *ngIf="isAuthorized"></my-heroes>
30
- <my-heroes id="unauthorized" *ngIf="!isAuthorized"></my-heroes>
31
- ''' ,
32
- directives: const [CarComponent , HeroesComponent , InjectorComponent , ProvidersComponent ],
19
+ <h1>{{title}}</h1>
20
+ <my-car></my-car>
21
+ <my-injectors></my-injectors>
22
+ <my-tests></my-tests>
23
+ <h2>User</h2>
24
+ <p id="user">
25
+ {{userInfo}}
26
+ <button (click)="nextUser()">Next User</button>
27
+ <p>
28
+ <my-heroes id="authorized" *ngIf="isAuthorized"></my-heroes>
29
+ <my-heroes id="unauthorized" *ngIf="!isAuthorized"></my-heroes>''' ,
30
+ directives: const [
31
+ CarComponent ,
32
+ HeroesComponent ,
33
+ InjectorComponent ,
34
+ ProvidersComponent
35
+ ],
33
36
// #docregion providers
34
- providers: const [Logger , UserService , const Provider (Config , useValue: CONFIG )]
37
+ providers: const [
38
+ Logger ,
39
+ UserService ,
40
+ const Provider (AppConfig , useValue: config1)]
35
41
// #enddocregion providers
36
- )
42
+ )
37
43
class AppComponent {
38
- UserService _userService;
39
- String title;
44
+ final UserService _userService;
45
+ final String title;
40
46
41
47
//#docregion ctor
42
- AppComponent (Config config, this ._userService) {
43
- title = config.title;
44
- }
45
-
48
+ AppComponent (AppConfig config, this ._userService)
49
+ : title = config.title;
46
50
// #enddocregion ctor
51
+
47
52
bool get isAuthorized {
48
53
return user.isAuthorized;
49
54
}
@@ -56,8 +61,7 @@ class AppComponent {
56
61
return _userService.user;
57
62
}
58
63
59
- String get userInfo {
60
- return 'Current user, ${user .name }, is ${isAuthorized ? "" : "not" } authorized. ' ;
61
- }
64
+ String get userInfo => 'Current user, ${user .name }, is'
65
+ '${isAuthorized ? "" : " not" } authorized. ' ;
62
66
}
63
67
// #enddocregion
0 commit comments