Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jrwebdev/cce322385344b9c3a87b19baf347a40b to your computer and use it in GitHub Desktop.

Select an option

Save jrwebdev/cce322385344b9c3a87b19baf347a40b to your computer and use it in GitHub Desktop.
Angular 1 vs Angular 2 Factories and Values
// 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