import { Component, OnInit } from '@angular/core';
import { User } from './user';
import { UserService } from './user.service';
@Component({
selector: 'user',
template: `
<h1>Users:</h1>
<ul>
<li *ngFor="let u of users">{{u.name}}</li>
</ul>
<h1>USER:</h1>
<div>{{user.name}}</div>`
})
export class UsersComponent implements OnInit {
users: User[];
user: User = { "id": 0, "login": "", "pass": "", "name": " ", "inn": " ", "address": " ", "phone": " ", "balance": 0 };
constructor(private userService: UserService) { }
ngOnInit(): void {
this.getUsers();
this.getUser(+localStorage.getItem('curUser'));
}
getUsers() {
this.userService.getUsers()
.subscribe((userss) => {
this.users = userss;
// for (let u of userss) {
// console.log("[user.component:getUsers] forInSubscribe: " + u.id + ":" + u.name);
// }
});
}
getUser(id: number) {
this.userService.getById(id)
.subscribe((userss) => {
this.user = userss;
// console.log("[user.component:getUSER] user: " + this.user.id + ":" + this.user.name);
// for (let u of userss) {
// console.log("[user.component:getUSER] forInSubscribe: " + u.id + ":" + u.name);
// }
});
}
}
решилось поднятием macvtap интерфейсов.