I am trying to upgrade an Angular1 component and consume it in my Angular2 app by following the official Angular2 documentation here under "Using Angular 1 Component Directives from Angular 2 Code", but it gives the following error:
error_handler.js:54 TypeError: Cannot read property 'get' of undefined
at ChartDirective.UpgradeComponent (upgrade_component.js:97)
Upon closer inspection on line 97, this.$inspector is undefined:
My code is very simple:
import { Directive, ElementRef, Injector } from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';
export const coolComponent = {
template: 'cool',
controller: function() {
}
};
@Directive({
selector: 'app-chart'
})
export class ChartDirective extends UpgradeComponent {
constructor(elementRef: ElementRef, injector: Injector) {
super('coolComponent', elementRef, injector);
}
}
My main.ts for bootstrapping is:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
Here is the simplified version of the problem, with minimal reproduction steps: https://github.com/dolanmiu/angular2-upgrade-test
It is generated by angular-cli