2018-05-29 22:35:48 +00:00
|
|
|
import {HttpClient} from '@angular/common/http';
|
2019-03-22 03:59:44 +00:00
|
|
|
import {Component} from '@angular/core';
|
2018-05-29 22:35:48 +00:00
|
|
|
import {Observable} from 'rxjs';
|
|
|
|
|
import {map, startWith} from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-component',
|
|
|
|
|
template: `
|
|
|
|
|
<hello-world-app></hello-world-app>
|
|
|
|
|
<div>The current time is {{ time$ | async }}</div>
|
2019-03-22 03:59:44 +00:00
|
|
|
<router-outlet></router-outlet>
|
|
|
|
|
`
|
|
|
|
|
})
|
2018-05-29 22:35:48 +00:00
|
|
|
export class AppComponent {
|
2019-03-22 03:59:44 +00:00
|
|
|
constructor(private http: HttpClient) {}
|
2018-05-29 22:35:48 +00:00
|
|
|
|
2019-03-22 03:59:44 +00:00
|
|
|
time$: Observable<string> =
|
2020-11-16 21:37:09 +00:00
|
|
|
this.http.get('https://worldtimeapi.org/api/timezone/America/Los_Angeles.json')
|
2020-08-28 17:21:28 +00:00
|
|
|
.pipe(map((result: any) => result.datetime), startWith(['...']));
|
2018-05-29 22:35:48 +00:00
|
|
|
}
|