2015-11-06 07:26:24 -05:00
|
|
|
@cheatsheetSection
|
|
|
|
Dependency injection configuration
|
2015-11-13 02:14:12 -05:00
|
|
|
@cheatsheetIndex 9
|
2015-11-06 07:26:24 -05:00
|
|
|
@description
|
2015-12-09 13:22:40 -05:00
|
|
|
{@target js ts}`import {provide} from 'angular2/angular2';`{@endtarget}
|
|
|
|
{@target dart}`import 'package:angular2/angular2.dart';`{@endtarget}
|
2015-11-06 07:26:24 -05:00
|
|
|
|
|
|
|
@cheatsheetItem
|
2015-12-09 07:33:42 -05:00
|
|
|
syntax:
|
|
|
|
`provide(MyService, {useClass: MyMockService})`|`provide`|`useClass`
|
|
|
|
description:
|
2015-11-06 07:26:24 -05:00
|
|
|
Sets or overrides the provider for MyService to the MyMockService class.
|
|
|
|
|
|
|
|
|
|
|
|
@cheatsheetItem
|
2015-12-09 07:33:42 -05:00
|
|
|
syntax:
|
|
|
|
`provide(MyService, {useFactory: myFactory})`|`provide`|`useFactory`
|
|
|
|
description:
|
2015-11-06 07:26:24 -05:00
|
|
|
Sets or overrides the provider for MyService to the myFactory factory function.
|
|
|
|
|
|
|
|
|
|
|
|
@cheatsheetItem
|
2015-12-09 07:33:42 -05:00
|
|
|
syntax:
|
|
|
|
`provide(MyValue, {useValue: 41})`|`provide`|`useValue`
|
|
|
|
description:
|
2015-11-06 07:26:24 -05:00
|
|
|
Sets or overrides the provider for MyValue to the value 41.
|
|
|
|
|