我正在研究离子项目。这里按钮点击,请求是过程和数据被接收为示出以下内容:如何在angular2或Ionic中应用* ngFor
public login() {
//this.showLoading()
var test33;
this.auth.login(this.registerCredentials).subscribe(data => {
console.log(data["_body"])
test33 = data["_body"]
console.log(test33)
},
error => {
this.showError(error);
});
}
鉴于:
<ion-row class="logo-row">
<ion-col></ion-col>
<h2 *ngFor="let user0 of test33">{{ user0.name }}</h2>
<ion-col width-67>
<img src="http://placehold.it/300x200"/>
</ion-col>
<ion-col></ion-col>
</ion-row>`
在控制台I接收到该数据中test33变量为:
[{"id":1,"role_id":1,"name":"Dr. Admin","email":"[email protected]","avatar":"\/user\/1\/profile\/HR1-dummy-avater.png","password":"$2y$10$iEpnh6pJ09rxH5NFFCVzaewBCxC\/FHZuHnkWA6qUrOBO3tYIBbsVC","remember_token":"VgwXUdIpL6EqW7Fp66VGRPjSKE727Inc4MTseJQq84cTCglkS335KCqVnavu","created_at":"2017-05-25 22:46:10","updated_at":"2017-06-14 05:19:52","is_feature":null}]
但{{user0.name}}
不返回名称。
请指出我犯错的地方。
如何将其声明为属性。因为现在当我注释掉'var test33'并将'test33'更改为this.test33'时,在'LoginPage'类型中不存在'Property'test33'的错误。' – Mohammed
编辑后的回答为 –