无法为 angular 打字稿创建复杂的界面
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;
}
}
我想获取每个用户的评论数组,但我需要创建一个如图所示的界面。
除了这个 属性 我可以得到所有东西,所以在我的代码中我是这样的:
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;
}
}