Я использую asyn c pipe в своем шаблоне для Observable:
applicants$: Observable<UserProfile[]>;
ngOnInit() {
this.applicants$ = this.store.pipe(
select(fromRootUserProfileState.getUserProfiles)
) as Observable<UserProfile[]>;
}
Вот интерфейс UserProfile.ts:
import { Role } from './role/role';
import { Country } from './Country';
export interface UserProfile {
id?: number;
fullName?: string;
roles?: Role[];
windowsAccount?: string;
firstName?: string;
lastName?: string;
email?: string;
managerName?: string;
managerId?: number;
managerEmail?: string;
companyId?: number;
companyName?: string;
countryId?: number;
country?: Country;
countryName?: string;
}
А вот userProfile.service
getUserProfiles(): Observable<UserProfile[]> {
return this.http.get<UserProfile[]>(
this.baseUrl + 'userprofiles/getuserprofiles'
);
}
В шаблоне, который я использовал ngFor для итерации по Observable с помощью asyn c pipe:
<mat-form-field
fxFlex="22"
appearance="outline"
*ngIf="applicants$ | async as applicants"
>
<mat-label>Applicant</mat-label>
<mat-icon matPrefix>person</mat-icon>
<mat-select
placeholder="Applicant"
name="applicant"
[(ngModel)]="this.searchPurchaseOrder.applicantId"
>
<mat-option *ngFor="let ap of applicants" [value]="ap.id">
ap.fullName
</mat-option>
</mat-select>
</mat-form-field>
Однако, вот ошибка, которую я получаю: ![enter image description here](https://i.stack.imgur.com/S5fkQ.png)
Вот форма данных из магазина. Он населен, поэтому там нет проблем: ![enter image description here](https://i.stack.imgur.com/gdTag.png)