在Angular组件中使用angularJS指令时出现StaticInjectorError(AppModule)错误

时间:2019-02-18 15:05:42

标签: angularjs angular

我正在尝试升级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!

这里是什么问题?

0 个答案:

没有答案