Hello everyone, I could use some assistance with a particular issue I'm facing.
Below is the code snippet from my angular 1.x app.js:
angular.module('app', []);
angular.module('app.test', ['app'])
.config(($stateProvider) =>
$stateProvider.state('base', {
url: '/',
controller: 'TestStateCtrl',
resolve: {
authenticationCheck: ['angularNg1Service', angularNg1Service=> {
angularNg1Service.test1();
}]
}
})
})
.run((angularNg1Service) => {
angularNg1Service.test2();
});
Here is the code for my angularNg1Service:
angular.module('app')
.service('angularNg1Service',
function (angularNg2Service} {
//some code here
}
The angularNg2Service is downgraded before the .run
function of the angular 1.x module is executed:
window['angular']
.module('app')
.factory(
'angularNg2Service',
upgradeAdapter.downgradeNg2Provider(AngularNg2Service)
);
However, I am encountering an error message:
Cannot read property 'injector' of null
This error occurs when the .run
function of the angular 1.x module starts.
Below is my main.ts file:
import { upgradeAdapter } from './upgradeAdapter';
import { bootstrapNg1Components } from './app/ng1Components';
bootstrapNg1Components(upgradeAdapter);// this function downgrades my AngularNg2Service
upgradeAdapter.bootstrap(document.querySelector('html'), ['app.start']);
I have searched for similar issues, but haven't been able to find a solution.
I have several Angular2 Services that are successfully downgraded. The problem seems to be isolated to one specific service that is injected into an Angular1 service used in the .run
function.