我想让用户能够选择他们预先输入的电子邮件,但是当我使用ng-options并且我尝试了ngFor但它似乎仍然没有用,我做错了什么的?
transfer.component.html
while self.valid_proof(last_proof, proof) is False:
proof += 1
if proof % 1000 == 0:
await asyncio.sleep(1)
transfer.component.ts
<form (ngSubmit)="transFunds()" >
<div class="container">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<select [ngModel]="selectedName" (ngModelChange)="updateSelectedValue($event)">
<option *ngFor ="let recipient of recipients" value="{{recipient.emailTo}}">{{recipient.emailTo}}</option>
</select>
</div>
</div>
<div class="row">
<div class="row">
<p><input type="number" placeholder="Amount Transfering" [(ngModel)]="amount"></p>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<p><button class="btn btn-primary" type="submit">Send</button> </p>
</div>
</div>
</div>
</form>
答案 0 :(得分:1)
你正在混合angularjs和angular语法,它应该是,
<select class="form-control" name="someDrpDown" [(ngModel)]="selectedName">
<option *ngFor="let recpient of recipients" [ngValue]="recipient">
{{recpient.email}}
</option>
</select>
答案 1 :(得分:0)
我在我的代码中这样做,使用角度js 2中的*ngfor
<select [(ngModel)]="selectedName"="selectedName"
(ngModelChange)="updateSelectedValue($event)">
<option *ngFor ="let recipient of recipients"
value="{{recipient.email}}">{{recipient.email}}</option>
</select>
我认为value="{{recipient.email}}"
需要替换为收据的ID,因此它会像value="{{recipient.Id}}"
答案 2 :(得分:0)
或者您可以创建自定义指令,例如* ngFor。
实现我自己的ngFor指令,它能够迭代ES6迭代。