@@ -752,17 +752,17 @@ code-example(format, language="html").
752
752
- var lang = current .path [1 ]
753
753
- var objectexamples = lang == ' dart' ? ' a string or list literal, or maybe a function' : ' a string, a function, or an object'
754
754
// Is function injection useful? Should we show it?
755
- - var hashes = lang == ' dart' ? ' They might be maps like this one:' : ' They tend to be object hashes like this one:'
756
755
:marked
757
756
### Non-class dependencies
758
757
759
758
What if the dependency value isn't a class?
760
759
Sometimes the thing we want to inject is #{objectexamples}.
760
+ // #enddocregion tokens-non-class-deps-1
761
761
762
-
762
+ // TS/JS only
763
+ :marked
763
764
Applications often define configuration objects with lots of small facts like the title of the application or the address of a web API endpoint.
764
- These configuration objects aren't always instances of a class. #{hashes}
765
- // #enddocregion tokens-non-class-deps-1
765
+ These configuration objects aren't always instances of a class. They tend to be object hashes like this one:
766
766
+ makeExample('dependency-injection/ts/app/app.config.ts' ,'config' ,'app/app-config.ts (excerpt)' )( format ='.' )
767
767
768
768
// TypeScript only?
@@ -805,9 +805,10 @@ code-example(format, language="html").
805
805
// #docregion tokens-opaque-2
806
806
- var lang = current .path [1 ]
807
807
- var decorated = lang == ' dart' ? ' annotated' : ' decorated'
808
+ - var configuration = lang == ' dart' ? ' ' : ' configuration'
808
809
:marked
809
- Now we inject the configuration object into any constructor that needs it, with
810
- the help of an `@Inject` #{decorator} that tells Angular how to find the configuration dependency value.
810
+ Now we can inject the #{ configuration} object into any constructor that needs it, with
811
+ the help of an `@Inject` #{decorator} that tells Angular how to find the #{ configuration} dependency value.
811
812
// #enddocregion tokens-opaque-2
812
813
+ makeExample('dependency-injection/ts/app/providers.component.ts' ,'provider-9b-ctor' )( format ="." )
813
814
@@ -819,10 +820,9 @@ code-example(format, language="html").
819
820
:marked
820
821
// end typescript only
821
822
822
- // #docregion tokens-opaque-3
823
+ // Skip for Dart (we have another example)
823
824
:marked
824
825
Or we can provide and inject the configuration object in our top-level `AppComponent`.
825
- // #enddocregion tokens-opaque-3
826
826
+ makeExample('dependency-injection/ts/app/app.component.ts' ,'providers' , 'app/app.component.ts (providers)' )( format ="." )
827
827
+ makeExample('dependency-injection/ts/app/app.component.ts' ,'ctor' , 'app/app.component.ts (constructor)' )( format ="." )
828
828
0 commit comments