Created
September 18, 2020 04:41
-
-
Save jcamilom/5c8887bf1ba907f834031ce16a34bc9c 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: 'app-root', | |
template: ` | |
<multi-check-field [formControl]="multiCheckControl"> | |
<simple-check-option *ngFor="let subject of subjects" | |
[value]="subject" [label]="subject.label"> | |
</simple-check-option> | |
</multi-check-field> | |
<button (click)="setTestValue()">Set Test Value</button> | |
Control value: <pre>{{ multiCheckControl.value | json }}</pre> | |
`, | |
}) | |
export class AppComponent { | |
public subjects = [ | |
{ code: '001', label: 'Math' }, | |
{ code: '002', label: 'Science' }, | |
{ code: '003', label: 'History' }, | |
]; | |
public multiCheckControl = new FormControl(); | |
setTestValue() { | |
const testValue = [this.subjects[0], this.subjects[1]]; | |
this.multiCheckControl.setValue(testValue); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment