当尝试获取state
数据时,我收到此TypeError:
无法读取未定义的属性“状态”
public addreq=(userId)=>{
let data:any ={
senderId:this.userInfo.userId,
recevierId:userId,
state:'request'
}
this.socketS.requestsend(data)
this.users['source']=data
console.log('addreq',this.users)
};
<div class="modal-body" >
<div *ngFor ="let user of users | userfilter:search; let i = index;" [ngClass]="{'active':user}">
<div class="text-center" *ngIf="user.userId!==userInfo.userId">
<p>{{user.username}}</p>
<button class='btn btn-primary' [ngClass]="{'hide':user.source.state==='request'}" (click)="addreq(userId)">add</button>
</div>
</div>
</div>
答案 0 :(得分:0)
删除
this.users['source']=data
并添加
for(user of this.users) user.source=data;