Created
May 22, 2020 08:24
-
-
Save Armenvardanyan95/eae70980c9e1f21437099f06a40b5d4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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