#object
[
{
"id": 1,
"description": "1 - Gulf Coast"
},
{
"id": 2,
"description": "10 - West Great Lakes"
},
{
"id": 3,
"description": "11 - California"
},
]
#html code
<mat-form-field appearance="fill" >
<mat-label>Region</mat-label>
<mat-select [(ngModel)]="territoryAssignmentFields.region" name="region">
<mat-option *ngFor="let region of regions" [value]="region.id">{{ region.description }}</mat-option>
</mat-select>
</mat-form-field>
How do we parse on the angular template that the value of mat-select option will be the id from the description object for example based on the object below the [value]
should be:
1, 10, 11.
It should get the id or number from the description and then use it as [value]
of mat-select option.
Can we parse that on the template? Thanks.
#tscode
getregion() {
this.searchString = "";
this._pickListService.getregion(this.accountId,this.searchString).subscribe(
res => {
this.regions = res.data;
console.log(" this.regions", this.regions)
},
err => {
console.log('Filtered Territory Assignments Region Error')
console.log(err);
}
)
}