Gökhan Sari
1 min readAug 3, 2017

--

Ben Mamia

Yes it is possible to use an ng1 service in an Angular 2 component.

  1. The ng1 service must be declared in the ng1-upgrade-shared.providers.ts and ng1-upgrade-shared.module.ts file
  2. Your component must be declared as lazy in your app.routing.ts file like {path: ‘walkthrough’, loadChildren: ‘./walkthrough/walkthrough.module#WalkthroughModule’},
  3. Use the @Inject to use the ng1 service in your component. Declare it in the component’s constructor like @Inject(‘$translate’) private $translate:any

I hope that helps, cheers

--

--

Gökhan Sari
Gökhan Sari

Written by Gökhan Sari

A professional software engineer at Allianz (previously UBS). 10 years of experience in the IT industry. BSc in computer science at the University of London

No responses yet