Skip to content

Commit 64bce18

Browse files
chalinfilipesilva
authored andcommitted
e2e(dependency-injection): fix for Dart and simplification for TS
Fixes angular#2493 No need to dual boot `AppComponent` and `ProvidersComponent` only to ensure that we could demo optional injection; instead just inject null for the `@Optional` constructor parameter type. No prose is affected by these changes.
1 parent 4a4144e commit 64bce18

File tree

8 files changed

+12
-8
lines changed

8 files changed

+12
-8
lines changed

public/docs/_examples/dependency-injection/dart/lib/app_component.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import 'providers_component.dart';
2222
<button (click)="nextUser()">Next User</button>
2323
<p>
2424
<my-heroes id="authorized" *ngIf="isAuthorized"></my-heroes>
25-
<my-heroes id="unauthorized" *ngIf="!isAuthorized"></my-heroes>''',
25+
<my-heroes id="unauthorized" *ngIf="!isAuthorized"></my-heroes>
26+
<my-providers></my-providers>
27+
''',
2628
directives: const [
2729
CarComponent,
2830
HeroesComponent,

public/docs/_examples/dependency-injection/dart/lib/providers_component.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ class Provider9Component implements OnInit {
224224

225225
// Sample providers 1 to 7 illustrate a required logger dependency.
226226
// Optional logger, can be null.
227-
@Component(selector: 'provider-10', template: '{{log}}')
227+
@Component(
228+
selector: 'provider-10',
229+
template: '{{log}}',
230+
providers: const [const Provider(Logger, useValue: null)]
231+
)
228232
class Provider10Component implements OnInit {
229233
final Logger _logger;
230234
String log;

public/docs/_examples/dependency-injection/dart/web/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@
1010
</head>
1111
<body>
1212
<my-app>Loading...</my-app>
13-
<my-providers>Loading my-providers ...</my-providers>
1413
</body>
1514
</html>
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import 'package:angular2/platform/browser.dart';
22

33
import 'package:dependency_injection/app_component.dart';
4-
import 'package:dependency_injection/providers_component.dart';
54

65
void main() {
76
//#docregion bootstrap
87
bootstrap(AppComponent);
98
//#enddocregion bootstrap
10-
bootstrap(ProvidersComponent);
119
}

public/docs/_examples/dependency-injection/ts/app/app.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { UserService } from './user.service';
2222
<p>
2323
<my-heroes id="authorized" *ngIf="isAuthorized"></my-heroes>
2424
<my-heroes id="unauthorized" *ngIf="!isAuthorized"></my-heroes>
25+
<my-providers></my-providers>
2526
`,
2627
providers: [Logger]
2728
})

public/docs/_examples/dependency-injection/ts/app/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import {
5353
{ provide: APP_CONFIG, useValue: HERO_DI_CONFIG }
5454
],
5555
// #enddocregion ngmodule-providers
56-
bootstrap: [ AppComponent, ProvidersComponent ]
56+
bootstrap: [ AppComponent ]
5757
})
5858
export class AppModule { }
5959
// #enddocregion ngmodule

public/docs/_examples/dependency-injection/ts/app/providers.component.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ let some_message = 'Hello from the injected logger';
229229

230230
@Component({
231231
selector: 'provider-10',
232-
template: template
232+
template: template,
233+
providers: [{ provide: Logger, useValue: null }]
233234
})
234235
export class Provider10Component implements OnInit {
235236
log: string;

public/docs/_examples/dependency-injection/ts/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
<body>
2424
<my-app>Loading my-app ...</my-app>
25-
<my-providers>Loading my-providers ...</my-providers>
2625
</body>
2726

2827
</html>

0 commit comments

Comments
 (0)