I use mat-select and try to set default value after options are loaded. My questions are:
1. Is it possible to set an items while populating the select list? Here is the config of y select list where I set the options:
this.listControls = [
{
id: 'employee',
type: 'select',
options: this.listEmployees().pipe(
map((list: PaginatedList) => {
return list.items.map(x => {
x.name = `${x.name} (${x.count})`;
return x;
});
})
)
},
];
2. Is it possible to set default option (make one of the item selected) without using ngModel
? I simply have an object value but I cannot make the it to be selected?
employee = {
id: 100,
name: 'Jonathan'
}
I also try to apply a filter to this.listControls[0]
, but as it is filled 'observable', it does not work:
const test = this.listControls[0].options.filter(x => x.id === 100);