parent
1ac07757dd
commit
897bd18fbc
|
@ -185,8 +185,7 @@ is available to <code>declarations</code> of this module.</p>
|
|||
</td>
|
||||
</tr><tr>
|
||||
<td><code><b>@Injectable()</b><br>class MyService() {}</code></td>
|
||||
<td><p>Declares that a class has dependencies that should be injected into the constructor when the dependency injector is creating an instance of this class.
|
||||
</p>
|
||||
<td><p>Declares that a class can be provided and injected by other classes. Without this decorator, the compiler won't generate enough metadata to allow the class to be created properly when it's injected somewhere.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody></table>
|
||||
|
|
|
@ -31,15 +31,20 @@ export type InjectableProvider = ValueSansProvider | ExistingSansProvider |
|
|||
*/
|
||||
export interface InjectableDecorator {
|
||||
/**
|
||||
* Decorator that marks a class as available to `Injector` for creation.
|
||||
* Decorator that marks a class as available to be
|
||||
* provided and injected as a dependency.
|
||||
*
|
||||
* @see [Introduction to Services and DI](guide/architecture-services)
|
||||
* @see [Dependency Injection Guide](guide/dependency-injection)
|
||||
*
|
||||
* @usageNotes
|
||||
*
|
||||
* The following example shows how service classes are properly marked as
|
||||
* injectable.
|
||||
* Marking a class with `@Injectable` ensures that the compiler
|
||||
* will generate the necessary metadata to create the class's
|
||||
* dependencies when the class is injected.
|
||||
*
|
||||
* The following example shows how a service class is properly
|
||||
* marked so that a supporting service can be injected upon creation.
|
||||
*
|
||||
* <code-example path="core/di/ts/metadata_spec.ts" region="Injectable"
|
||||
* linenums="false"></code-example>
|
||||
|
|
Loading…
Reference in New Issue