Seeking assistance with setting the options of a mat-select in Angular 4.
The issue at hand is as follows:
1. Initially, there are two variables: options
and checkedOptions
options: string[];
checkedOptions: string[] //Retrieved from the database;
2. The options
variable contains all available options, while the checkedOptions
variable holds data fetched from the database like so:
options = ["o1", "o2", "o3", "o4", ... "oN"]
checkedOptions = ["o2", "o4"]
3. The options are displayed using the following code snippet:
<mat-form-field floatPlaceholder="always" color="accent" class="input-all">
<mat-select multiple placeholder="{{ par.label }}">
<mat-option *ngFor="let op of options" [value]="op">{{ op }}</mat-option>
</mat-select>
</mat-form-field>
- The challenge is to display only those options in the
options
list that are also present in thecheckedOptions
list. How can this be achieved?
Your guidance on this matter would be greatly appreciated.