我正在尝试升级angularjs指令以将其用于我的angular组件。
import {Directive, ElementRef, HostListener, Input, Injector} from '@angular/core';
import { UpgradeComponent } from '@angular/upgrade/static';
@Directive({
selector:'[analyticsEvent]'
})
export class MyDirective extends UpgradeComponent {
@Input('analyticsEvent') appHighlight: string;
count = 1;
constructor(elementRef: ElementRef, injector: Injector) {
super('analyticsEvent', elementRef, injector);
}
@HostListener('click', ['$event'])
clickEvent(event) {
this.count++
console.log('this.count++')
event.preventDefault();
event.stopPropagation();
}
}
它抛出以下错误:
ERROR Error: StaticInjectorError(AppModule)[$injector]:
StaticInjectorError(Platform: core)[$injector]:
NullInjectorError: No provider for $injector!
这里是什么问题?