Error: Lifecycle interface ‘AfterViewInit’ should be implemented for method ‘ngAfterViewInit
Example code throwing that error:
@Directive({
selector: '[appYourDirective]'
})
export class YourDirective {
constructor(private element: ElementRef) {}
ngAfterViewInit() {
}
}
Solution: Implement your class with “implements AfterViewInit”
import { AfterViewInit, Directive, ElementRef, Input } from '@angular/core';
@Directive({
selector: '[appYourDirective]'
})
export class YourDirective implements AfterViewInit {
constructor(private element: ElementRef) {}
ngAfterViewInit() {
}
}
The issue will be fixed after adding AfterViewInit implements.