This repository was archived by the owner on Dec 4, 2017. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +19
-17
lines changed
public/docs/_examples/dependency-injection/dart/lib Expand file tree Collapse file tree 4 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -37,16 +37,16 @@ import 'providers_component.dart';
37
37
providers: const [
38
38
Logger ,
39
39
UserService ,
40
- const Provider (appConfig , useValue: config1)]
40
+ const Provider (AppConfig , useValue: config1)]
41
41
// #enddocregion providers
42
42
)
43
43
class AppComponent {
44
44
final UserService _userService;
45
45
final String title;
46
46
47
47
//#docregion ctor
48
- AppComponent (@Inject (appConfig) Map config, this ._userService) :
49
- title = config[ ' title' ] ;
48
+ AppComponent (AppConfig config, this ._userService)
49
+ : title = config. title;
50
50
// #enddocregion ctor
51
51
52
52
bool get isAuthorized {
Original file line number Diff line number Diff line change @@ -22,13 +22,13 @@ import 'logger_service.dart';
22
22
providers: const [
23
23
Logger ,
24
24
// #docregion provider-config
25
- const Provider (appConfig , useValue: config1)
25
+ const Provider (AppConfig , useValue: config1)
26
26
])
27
27
class AppComponent {
28
28
final String title;
29
29
30
30
// #docregion ctor
31
- AppComponent (@Inject (appConfig) Map config)
32
- : title = config[ ' title' ] ;
31
+ AppComponent (AppConfig config)
32
+ : title = config. title;
33
33
// #enddocregion
34
34
}
Original file line number Diff line number Diff line change 2
2
// #docregion token
3
3
import 'package:angular2/core.dart' ;
4
4
5
- const appConfig = const OpaqueToken ('app.config' );
6
- // #enddocregion token
7
-
8
5
//#docregion config
9
- const config1 = const < String , String > {
10
- 'apiEndpoint' : 'api.heroes.com' ,
11
- 'title' : 'Dependency Injection'
12
- };
6
+ @Injectable ()
7
+ class AppConfig {
8
+ final apiEndpoint;
9
+ final String title;
10
+
11
+ const AppConfig (this .apiEndpoint, this .title);
12
+ }
13
+
14
+ const config1 = const AppConfig ('api.heroes.com' , 'Dependency Injection' );
13
15
//#enddocregion config
Original file line number Diff line number Diff line change @@ -221,21 +221,21 @@ class ProviderComponent8 {
221
221
selector: 'provider-9' ,
222
222
template: '{{log}}' ,
223
223
// #docregion providers-9
224
- providers: const [const Provider (appConfig , useValue: config1)]
224
+ providers: const [const Provider (AppConfig , useValue: config1)]
225
225
// . . .
226
226
// #enddocregion providers-9
227
227
)
228
228
class ProviderComponent9 implements OnInit {
229
- final Map < String , String > _config;
229
+ AppConfig _config;
230
230
String log;
231
231
232
232
// #docregion providers-9
233
- ProviderComponent9 (@Inject (appConfig) this ._config);
233
+ ProviderComponent9 (AppConfig this ._config);
234
234
235
235
// #enddocregion providers-9
236
236
@override
237
237
void ngOnInit () {
238
- log = 'appConfigToken Application title is ${_config [ " title" ] }' ;
238
+ log = 'appConfigToken Application title is ${_config . title }' ;
239
239
}
240
240
}
241
241
You can’t perform that action at this time.
0 commit comments