Using the process described here , I am trying to introduce Angular 1 services into an Angular 4 application. The application loads in hybrid mode (and works because I have several Angular 4 components and services).
Whenever I try to enter an Angular 1 service, I get I can not read the "get" property from undefined .
upgraded-providers.ts:
import {LinksService} from "./+services/links/links"; export function linksServiceFactory(i: any) { return i.get('bfLinksService');
My Angular 4 service, which is trying to use LinksService, looks like this:
@Injectable() export class EntityService { constructor ( private http: Http, private links: LinksService ) { } get(id: string): Observable<OrgDetails> {
Finally, the LinksService (an Angular 1 service written in Typescript) looks like this:
export class LinksService { static $inject = ["$log", "$location", PROPERTIES_SERVICE]; private contentHost : string; private thisAppHost : string; constructor (private $log : ng.ILogService, private $location : ng.ILocationService, private props : IPropertiesService) { this.init(); }
Loading material and module:
@NgModule({ imports: [ BrowserModule, HttpModule, UpgradeModule, ], declarations: [ AppComponent, OrgSummaryComponent, ], providers: [ EntityService, linksServiceProvider ], bootstrap: [ AppComponent, ], }) export class AppModule { ngDoBootstrap() { // Does nothing by design. // This is to facilitate "hybrid bootstrapping" } } platformBrowserDynamic().bootstrapModule(AppModule).then(platformRef => { const upgrade = platformRef.injector.get(UpgradeModule) as UpgradeModule; upgrade.bootstrap(document.body, [AppModuleName], {strictDi: false}); });
Angular 1 (legacy) everything works fine.
It seems that Angular cannot find the $ injector, but shouldn't it be there independently?
Thanks so much for any suggestions, Jeff