I am trying to incorporate an AngularJS service into my Angular project.
Below is my main.ts file:
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
import {AppModule} from './app/app.module';
import {UpgradeModule} from "@angular/upgrade/static";
import {environment} from './environments/environment';
platformBrowserDynamic().bootstrapModule(AppModule)
.then(ref => {
const upgrade = ref.injector.get(UpgradeModule) as UpgradeModule;
upgrade.bootstrap(document.body, ['dmdWorkplace', 'dmdLogin'], {strictDi: true});
})
.catch(err => console.log(err));
And here is my app.module.ts file:
//@angular
import {BrowserModule} from '@angular/platform-browser';
import {CUSTOM_ELEMENTS_SCHEMA, Inject, NgModule} from '@angular/core';
import {UpgradeModule} from '@angular/upgrade/static';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {HttpClientModule} from '@angular/common/http';
//Modules
import {AppRoutingModule} from './app-routing.module';
import {MaterialModule} from './material.module';
//Components
import {DmdWhlComponentMain} from './main/dmd-whl.component.main';
import {DmdWhlComponentRegistries} from './registries/dmd-whl.component.registries';
//Services
import {DmdWhlGlobalService} from './services/dmd-whl.global.service';
import {DmdWhlLabelService} from './services/dmd-whl.label.service';
import {TranslateModule, TranslateService} from '@ngx-translate/core';
import {DOCUMENT} from "@angular/common";
@NgModule({
// content goes here (unchanged)
})
export class AppModule {
// content goes here (unchanged)
}
The error message received is:
Error: Trying to get the AngularJS injector before it has been set.
at injectorFactory (static.js:678)
at _callFactory (core.js:10645)
at _createProviderInstance$1 (core.js:10599)
at initNgModule (core.js:10549)
at new NgModuleRef_ (core.js:11792)
at createNgModuleRef (core.js:11782)
at Object.debugCreateNgModuleRef [as createNgModuleRef] (core.js:14092)
at NgModuleFactory_.create (core.js:15216)
at eval (core.js:5370)
at ZoneDelegate.invoke (zone.js:392)