Skip to content

Instantly share code, notes, and snippets.

@Armenvardanyan95
Created May 22, 2020 08:24
Show Gist options
  • Save Armenvardanyan95/eae70980c9e1f21437099f06a40b5d4c to your computer and use it in GitHub Desktop.
Save Armenvardanyan95/eae70980c9e1f21437099f06a40b5d4c to your computer and use it in GitHub Desktop.
@Component({
selector: 'my-component',
template: `
<input [formControl]="control">
<button (click)="toggleEnabledState()">Toggle State</button>
`,
})
export class MyComponent implements OnInit {
control = new FormControl('Default Value');
ngOnInit() {
this.control.valueChanges.subscribe(console.log);
}
toggleEnabledState() {
this.control.enabled ? this.control.disable() : this.control.enable();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment