示例代码:
getUsers(): Observable {
return this.http.get('https://example.com/api/users');
}
示例代码:
users: User[];
ngOnInit() {
this.userService.getUsers().subscribe(
(data) => {
this.users = data;
},
(error) => {
console.log(error);
}
);
}
示例代码:
Name
Email
{{ user.name }}
{{ user.email }}