从Https读取Json

时间:2018-09-27 08:21:55

标签: angular

我需要从https站点读取json,然后在组件中构建了一个算法:

customersObservable: Observable <any []>;
 constructor (private httpClient: HttpClient) {}
 ngOnInit () {
         this.customersObservable = this.httpClient
             .request ("GET", "https://urlmysite.com", {responseType: "json", myparams})
             .do (console.log);
     }

在我的html中:

<ul * ngIf = "customersObservable | async as customers else empty">
   <li * ngFor = "let customer of customers">
....
   </ Li>
</ Ul>
<ng-template #empty> No Customers Yet </ ng-template>

不幸的是,“ customersObservable”对象似乎没有数据。 我错了吗?

大卫

0 个答案:

没有答案