有一个代码:
<select name="department" class="form-control select" [(ngModel)]="departments" formControlName="departmentControl">
<option *ngFor="let department of departments" [ngValue]="department" [selected]="department.id == this.departmentid">
{{ department.name }}
</option>
</select>
和功能:
isSelected(department): boolean {
debugger;
return department.id == this.departmentid;
}
department - 是用户详细信息组件的嵌套组件。在我第一次选择用户详细信息组件后,未选择部门。但第二次一切正常。哪里出错?
答案 0 :(得分:3)
您正在使用[selected]="department.id == this.departmentid"
[(ngModel)]
将[(ngModel)]="departments"
更改为[(ngModel)]="departmentid"
将[ngValue]="department"
更改为[ngValue]="department.id"
最后看起来应该是这样的:
<select name="department" class="form-control select" [(ngModel)]="departmentid" formControlName="departmentControl">
<option *ngFor="let department of departments" [ngValue]="department.id" >
{{ department.name }}
</option>
</select>
<强> WORKING DEMO 强>
答案 1 :(得分:1)
您的ngModel
错误,您应该将其departmentid
设置为ngValue
,<select name="department" class="form-control select" [(ngModel)]="departmentid" formControlName="departmentControl">
<option *ngFor="let department of departments" [ngValue]="department.id" [selected]="department.id == this.departmentid">
{{ department.name }}
</option>
</select>
应该是部门的ID,如下所示
TcpClient client = new TcpClient();
client.Connect(resolvedIpAddr, PORT_TLS_11);
Org.BouncyCastle.Security.SecureRandom sr = new Org.BouncyCastle.Security.SecureRandom();
TlsProtocolHandler handler = new TlsProtocolHandler(client.GetStream(), sr);
handler.Connect(new MyTlsClient());
有关详情,请参阅 answer