[英]Can't create a complex interface for angular typescript
我想為每個用戶獲取評論數組,但我需要創建一個像圖像中一樣的界面。
我可以得到除了這個屬性之外的所有東西,所以在我的代碼中我喜歡這樣:
personSubject = new BehaviorSubject<any>(null);
person$: Observable<any> = this.personSubject.asObservable();
getAllPosts(event?) {
this.authService.getAllPosts().pipe(takeUntil(this.destroy$)).subscribe((res: any) => {
console.log(res);
this.allPosts = res.length;
this.down = res.length;
this.personSubject.next(res.data.post)
})
}
*ngFor="let i=index; let post of person$ | async | sortPipe"
我如何處理這個界面?
像這樣的用戶嵌套界面
interface Response {
data: User;
status: string;
length: number;
}
interface User {
post: Post[];
}
interface Post {
allComments: Comment[];
author: Author;
comments: Comment[];
}
interface Comment {
commentBody: string;
userData: {
photo: string;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.