From 64bce18ea70e6d6f05431650c3e20991b6740f40 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Tue, 15 Nov 2016 14:58:56 -0800 Subject: [PATCH] e2e(dependency-injection): fix for Dart and simplification for TS Fixes #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. --- .../dependency-injection/dart/lib/app_component.dart | 4 +++- .../dependency-injection/dart/lib/providers_component.dart | 6 +++++- .../docs/_examples/dependency-injection/dart/web/index.html | 1 - .../docs/_examples/dependency-injection/dart/web/main.dart | 2 -- .../_examples/dependency-injection/ts/app/app.component.ts | 1 + .../_examples/dependency-injection/ts/app/app.module.ts | 2 +- .../dependency-injection/ts/app/providers.component.ts | 3 ++- public/docs/_examples/dependency-injection/ts/index.html | 1 - 8 files changed, 12 insertions(+), 8 deletions(-) diff --git a/public/docs/_examples/dependency-injection/dart/lib/app_component.dart b/public/docs/_examples/dependency-injection/dart/lib/app_component.dart index cb29545084..5339e55d02 100644 --- a/public/docs/_examples/dependency-injection/dart/lib/app_component.dart +++ b/public/docs/_examples/dependency-injection/dart/lib/app_component.dart @@ -22,7 +22,9 @@ import 'providers_component.dart';

- ''', + + + ''', directives: const [ CarComponent, HeroesComponent, diff --git a/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart b/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart index 08c9e542a8..16e248f000 100644 --- a/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart +++ b/public/docs/_examples/dependency-injection/dart/lib/providers_component.dart @@ -224,7 +224,11 @@ class Provider9Component implements OnInit { // Sample providers 1 to 7 illustrate a required logger dependency. // Optional logger, can be null. -@Component(selector: 'provider-10', template: '{{log}}') +@Component( + selector: 'provider-10', + template: '{{log}}', + providers: const [const Provider(Logger, useValue: null)] +) class Provider10Component implements OnInit { final Logger _logger; String log; diff --git a/public/docs/_examples/dependency-injection/dart/web/index.html b/public/docs/_examples/dependency-injection/dart/web/index.html index cd3dfdb6cf..8a89dc5d59 100644 --- a/public/docs/_examples/dependency-injection/dart/web/index.html +++ b/public/docs/_examples/dependency-injection/dart/web/index.html @@ -10,6 +10,5 @@ Loading... - Loading my-providers ... diff --git a/public/docs/_examples/dependency-injection/dart/web/main.dart b/public/docs/_examples/dependency-injection/dart/web/main.dart index 5ec8717ed2..06582f0fbb 100644 --- a/public/docs/_examples/dependency-injection/dart/web/main.dart +++ b/public/docs/_examples/dependency-injection/dart/web/main.dart @@ -1,11 +1,9 @@ import 'package:angular2/platform/browser.dart'; import 'package:dependency_injection/app_component.dart'; -import 'package:dependency_injection/providers_component.dart'; void main() { //#docregion bootstrap bootstrap(AppComponent); //#enddocregion bootstrap - bootstrap(ProvidersComponent); } diff --git a/public/docs/_examples/dependency-injection/ts/app/app.component.ts b/public/docs/_examples/dependency-injection/ts/app/app.component.ts index 9a50661a84..94e1f0b988 100644 --- a/public/docs/_examples/dependency-injection/ts/app/app.component.ts +++ b/public/docs/_examples/dependency-injection/ts/app/app.component.ts @@ -22,6 +22,7 @@ import { UserService } from './user.service';

+ `, providers: [Logger] }) diff --git a/public/docs/_examples/dependency-injection/ts/app/app.module.ts b/public/docs/_examples/dependency-injection/ts/app/app.module.ts index 5ef7678573..2929f502a2 100644 --- a/public/docs/_examples/dependency-injection/ts/app/app.module.ts +++ b/public/docs/_examples/dependency-injection/ts/app/app.module.ts @@ -53,7 +53,7 @@ import { { provide: APP_CONFIG, useValue: HERO_DI_CONFIG } ], // #enddocregion ngmodule-providers - bootstrap: [ AppComponent, ProvidersComponent ] + bootstrap: [ AppComponent ] }) export class AppModule { } // #enddocregion ngmodule diff --git a/public/docs/_examples/dependency-injection/ts/app/providers.component.ts b/public/docs/_examples/dependency-injection/ts/app/providers.component.ts index f8c7ee81fd..d74b25d780 100644 --- a/public/docs/_examples/dependency-injection/ts/app/providers.component.ts +++ b/public/docs/_examples/dependency-injection/ts/app/providers.component.ts @@ -229,7 +229,8 @@ let some_message = 'Hello from the injected logger'; @Component({ selector: 'provider-10', - template: template + template: template, + providers: [{ provide: Logger, useValue: null }] }) export class Provider10Component implements OnInit { log: string; diff --git a/public/docs/_examples/dependency-injection/ts/index.html b/public/docs/_examples/dependency-injection/ts/index.html index b7ef513c19..c3586c230e 100644 --- a/public/docs/_examples/dependency-injection/ts/index.html +++ b/public/docs/_examples/dependency-injection/ts/index.html @@ -22,7 +22,6 @@ Loading my-app ... - Loading my-providers ...