9.3: Following Functionality in Angular
Update UserService
followUser(id: number, recipientId: number) {
return this._http.post(this.baseUrl + 'users/' + id + '/follow/' + recipientId, {});
}Update MemberCardComponent
export class MemberCardComponent implements OnInit {
@Input() user: User;
constructor(private _authService: AuthService,
private _userService: UserService,
private _alertifyService: AlertifyService) { }
ngOnInit() {
}
followUser(id: number) {
this._userService.followUser(this._authService.decodedToken.nameid, id).subscribe(data => {
this._alertifyService.success('Now following: ' + this.user.knownAs);
}, error => {
this._alertifyService.error(error);
});
}
}Add Click Event to Template
Last updated