parent
c4a16feed2
commit
fe3b3180fb
@ -1,24 +1,41 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { FriendsService } from '../../services/friends/friends.service';
|
import { FriendsService } from '../../services/friends/friends.service';
|
||||||
import { User } from '../../model/User';
|
import { NgFor, NgIf } from '@angular/common';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-friend-page',
|
selector: 'app-friend-page',
|
||||||
imports: [],
|
imports: [NgFor, NgIf],
|
||||||
templateUrl: './friend-page.component.html',
|
templateUrl: './friend-page.component.html',
|
||||||
styleUrl: './friend-page.component.css'
|
styleUrls: ['./friend-page.component.css']
|
||||||
})
|
})
|
||||||
export class FriendPageComponent {
|
export class FriendPageComponent implements OnInit {
|
||||||
|
listFriend: {username: string, status: string}[] = [];
|
||||||
|
userId: string = "";
|
||||||
|
status: string = "";
|
||||||
|
|
||||||
private readonly listFriend : User[] = [];
|
constructor(private friendService: FriendsService) {
|
||||||
constructor(friendService : FriendsService){
|
|
||||||
friendService.getFriend().subscribe((data) => {
|
|
||||||
this.listFriend.push();
|
|
||||||
});;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.getFriendData();
|
||||||
|
console.log(this.listFriend)
|
||||||
|
}
|
||||||
|
|
||||||
|
private getFriendData(): void {
|
||||||
|
this.friendService.getFriend().subscribe((data: any[]) => {
|
||||||
|
if (data.length > 0) {
|
||||||
|
data.forEach(friend => {
|
||||||
|
let status = friend['status'];
|
||||||
|
let userId = friend['friend_user_id'];
|
||||||
|
this.friendService.getFriendById(userId).subscribe((friendData: any) => {
|
||||||
|
this.listFriend.push({
|
||||||
|
username: friendData.username,
|
||||||
|
status: status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue