我正在为这样的模板输入创建自动聚焦指令:
"26"
我有两个问题: 首先,我的自动对焦指令规范文件向我返回错误:
join
第二个错误是在控制台上,将我的自动指令注入组件的构造函数后,将“ autofocus”指令放置如下:
import { Directive,ElementRef,AfterContentInit } from '@angular/core';
@Directive({
selector: '[appAutofocus]',})
export class AutofocusDirective implements AfterContentInit {
constructor(private elementRef: ElementRef) {}
ngAfterContentInit() {
this.elementRef.nativeElement.focus();
}
}
我的控制台向我返回此消息: core.js:7187错误错误:未捕获(已承诺):NullInjectorError:StaticInjectorError(AppModule)[TabPensionInvaliditeComponent-> AutofocusDirective]: