Cannot read property 'nativeElement' of undefined - ngAfterViewInit
I'm trying to add a "clipboard" directive using this example . The example is now outdated so I have had to update how it is getting the nativeElement. I'm getting the error Cannot read property 'nativeElement' of undefined I have marked the error in the code with <===== error here: clipboard.directive.js import {Directive,ElementRef,Input,Output,EventEmitter, ViewChild, AfterViewInit} from "@angular/core"; import Clipboard from "clipboard"; @Directive({ selector: "[clipboard]" }) export class ClipboardDirective implements AfterViewInit { clipboard: Clipboard; @Input("clipboard") elt