Skip to content

Instantly share code, notes, and snippets.

@mfp22
Created March 5, 2020 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfp22/12c0d3c56db06d526b0aae289823e347 to your computer and use it in GitHub Desktop.
Save mfp22/12c0d3c56db06d526b0aae289823e347 to your computer and use it in GitHub Desktop.
import {Directive, Input} from '@angular/core';
import {NgControl} from '@angular/forms';
@Directive({
selector: '[setValue]',
})
export class SetValueDirective {
@Input()
set setValue(val: any) {
this.ngControl.control.setValue(val);
}
constructor(private ngControl: NgControl) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment