我正在开发一个离子应用程序,使用HTML文件中的* ngFor =“ let playerValue ofplayers”来获取价值
但是在插值{{playerValue.playerPhoto}}或playerValue.playerType时,例如在html中使用playerValue或playerType之类的playerValue的属性时出现错误:-
或
错误消息是-:
[角度]标识符'playerType'未定义。 '' 不含 这样的成员
或
[角度]标识符'playerPhoto'未定义。 '' 不含 这样的成员
注意:->>从中删除代码位时 哪个-| 搜索:条款|排序:{属性:列,订单:订单};
没有显示错误,所以问题在于添加管道
下面是我遇到错误的HTML
<ion-content no-padding>
<div class="create-team-section">
<ion-list class="team-create-list">
<div [ngSwitch]="playerType" *ngFor="let playerValue of players |
search : terms| sort: {property: column, order: order}; let i = index">
<div *ngSwitchCase="playerValue.playerType" ngSelected="selected">
<ion-item [class.active]="playerValue.isSelected? 'active' : null">
<ion-grid no-padding>
<!-- <a (click)="playerInfo()"><img src={{playerValue.playerPhoto}}></a> -->
<ion-row align-items-center [class.shake]="shake==playerValue.playerUid ? 'shake' : null">
<ion-col col-3>
<!-- <div class="create-team-imge" >
<img src={{playerValue.playerPhoto}}>
</div> -->
<div class="create-team-imge">
<ion-avatar item-star no-line>
<button (click)="playerinfo(i)"><img src={{playerValue.playerPhoto}}></button>
</ion-avatar>
<ion-badge>
<ion-icon name="information"></ion-icon>
</ion-badge>
</div>
</ion-col>
<ion-col col-md-9 col-9 (click)="setClickedRow(i)">
<ion-row align-items-center>
<ion-col col-md-8 col-7>
<p>{{playerValue.playerName}}</p>
<p>Selected By {{playerValue.selectedBy}}</p>
<p class="country" >{{playerValue.teamName}}</p>
<p class="points"> Points:
<span>{{playerValue.totalPoint}}</span>
</p>
</ion-col>
<ion-col col-md-4 col-5 class="cradit">
<p>
<span>{{playerValue.playerCreditPoint}}</span>
</p>
<button ion-button icon-only>
<ion-icon [name]="playerValue.isSelected? 'close' : 'ios-checkmark'"></ion-icon>
</button>
</ion-col>
</ion-row>
</ion-col>
</ion-row>
</ion-grid>
</ion-item>
</div>
</div>
</ion-list>
</div>
</ion-content>
ts文件
**export class CreateteamPage {
players: playerss [];**
在打字稿中,我已将接口类型为player []的播放器放到了
界面
export interface Playerss {
playerUid: string;
playerName: string;
playerPhoto: string;
country: string;
playerCreditPoint: any;
playerType: string;
teamName: string;
flag: number;
totalPoint: number;
status: boolean;
selectedBy: string;
c: string;
vc: string;
isSelected: boolean;
}
JSON数据->
http://magicmindpremier11.azurewebsites.net/api/Players/GetPlayers