Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hidegh/d75831ca82646fee929a518956f5a98a to your computer and use it in GitHub Desktop.
Save hidegh/d75831ca82646fee929a518956f5a98a to your computer and use it in GitHub Desktop.
import {NgControl} from "@angular/forms";
import {Directive, ElementRef} from "@angular/core";
@Directive({
selector: '[ngModel]', // or 'input, select, textarea' - but then your controls won't be handled and also checking for undefined would be necessary
})
export class NativeElementInjectorDirective {
constructor(private el: ElementRef, private control : NgControl) {
(<any>control.control).nativeElement = el.nativeElement;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment