You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
front/src/app/components/friend-page/friend-page.component.ts

42 lines
1.1 KiB

import { Component, OnInit } from '@angular/core';
import { FriendsService } from '../../services/friends/friends.service';
import { NgFor, NgIf } from '@angular/common';
@Component({
selector: 'app-friend-page',
imports: [NgFor, NgIf],
templateUrl: './friend-page.component.html',
styleUrls: ['./friend-page.component.css']
})
export class FriendPageComponent implements OnInit {
listFriend: {username: string, status: string}[] = [];
userId: string = "";
status: string = "";
constructor(private friendService: FriendsService) {
}
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
});
});
});
}
});
}
}