2017-07-04 10:58:20 -04:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
2018-01-17 15:01:53 +02:00
|
|
|
import { User, UserService } from './user.service';
|
2017-07-04 10:58:20 -04:00
|
|
|
|
2018-01-17 15:01:53 +02:00
|
|
|
// #docregion component-providers
|
2017-07-04 10:58:20 -04:00
|
|
|
@Component({
|
2018-01-17 15:01:53 +02:00
|
|
|
// #enddocregion component-providers
|
2017-07-04 10:58:20 -04:00
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
|
|
|
styleUrls: ['./app.component.css'],
|
2018-01-17 15:01:53 +02:00
|
|
|
// #docregion component-providers
|
2017-07-04 10:58:20 -04:00
|
|
|
providers: [UserService]
|
|
|
|
})
|
2018-01-17 15:01:53 +02:00
|
|
|
// #enddocregion component-providers
|
2017-07-04 10:58:20 -04:00
|
|
|
export class AppComponent implements OnInit {
|
|
|
|
title = 'Users list';
|
2021-05-08 16:02:03 +02:00
|
|
|
users: User[] = [];
|
2017-07-04 10:58:20 -04:00
|
|
|
|
|
|
|
constructor(private userService: UserService) { }
|
|
|
|
|
|
|
|
ngOnInit(): void {
|
2018-01-17 15:01:53 +02:00
|
|
|
this.userService.getUsers().then(users => this.users = users);
|
2017-07-04 10:58:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|