Skip to content

Instantly share code, notes, and snippets.

@jcamilom
Created September 18, 2020 04:41
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 jcamilom/5c8887bf1ba907f834031ce16a34bc9c to your computer and use it in GitHub Desktop.
Save jcamilom/5c8887bf1ba907f834031ce16a34bc9c to your computer and use it in GitHub Desktop.
@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