Created
November 15, 2016 00:23
-
-
Save jrwebdev/cce322385344b9c3a87b19baf347a40b to your computer and use it in GitHub Desktop.
Angular 1 vs Angular 2 Factories and Values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Angular 1 | |
| const module = angular.module('myModule', []); | |
| module.service('MyService', MyService); | |
| module.factory('MyFactory', MyFactory); | |
| module.value('MyValue', MyValue); | |
| /***************************************************************/ | |
| // Angular 2 | |
| import { NgModule } from '@angular/core'; | |
| @NgModule({ | |
| providers: [ | |
| MyService, | |
| {provide: MyFactory, useFactory: MyFactory}, | |
| {provide: MyValue, useValue: MyValue} | |
| ] | |
| }) | |
| export class MyModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment