我正在尝试将 import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-randomuser',
templateUrl: './randomuser.page.html',
styleUrls: ['./randomuser.page.scss'],
})
export class RandomuserPage implements OnInit {
public randomUser = [];
constructor(private httpClient: HttpClient) { }
get_users() {
this.httpClient.get("https://randomuser.me/api/?results=1")
.subscribe((res) => {
console.log(res);
this.randomUser[0] = res;
});
}
ngOnInit() {
}
}
集成到 <ion-header>
<ion-toolbar>
<ion-title>randomuser</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<button (click)="get_users()">GET /Users</button>
<ion-list>
<ion-item *ngFor="let ru of randomUser">
<h2>{{ru.gender}}</h2>
<p>{{ru.email}}</p>
</ion-item>
</ion-list>
</ion-content>
中。
首先,我用jhipster 6.0.1 分离了前端和后端。
背面和正面开始并很好地沟通。
当我在前端执行时,
nguniversal
我收到此错误:
无法读取未定义的属性“选项”。