将其转换为提交功能
Convert it to Submit Function
我怎样才能让这个表单在提交功能上工作。目前,我 select 选项并自动更改数据。我希望在更改发生之前先单击提交按钮。
<div class="select" >
<select class="form-control col-lg-8" #selectedValue name="selectedValue" id="selectedValue" [(ngModel)]="selectedValue[i]" (ngModelChange)="assignCorporationToManage($event)">
<option *ngFor="let corporation of user_corporations" [ngValue]="corporation">{{corporation.corp_name}}</option>
</select>
<button type="submit" class="btn btn-primary manage">Submit</button>
</div>
我假设在 assignCorporationToManage 方法中您需要当前选择的值只需删除 ngModelChange 并将其添加到提交方法函数中,例如
<div class="select" >
<select class="form-control col-lg-8" #selectedValue name="selectedValue" id="selectedValue" [(ngModel)]="selectedValue[i]" >
<option *ngFor="let corporation of user_corporations" [ngValue]="corporation">{{corporation.corp_name}}</option>
</select>
<button type="submit" class="btn btn-primary manage" (click)="assignCorporationToManage(selectedValue[i])">Submit</button>
</div>
我怎样才能让这个表单在提交功能上工作。目前,我 select 选项并自动更改数据。我希望在更改发生之前先单击提交按钮。
<div class="select" >
<select class="form-control col-lg-8" #selectedValue name="selectedValue" id="selectedValue" [(ngModel)]="selectedValue[i]" (ngModelChange)="assignCorporationToManage($event)">
<option *ngFor="let corporation of user_corporations" [ngValue]="corporation">{{corporation.corp_name}}</option>
</select>
<button type="submit" class="btn btn-primary manage">Submit</button>
</div>
我假设在 assignCorporationToManage 方法中您需要当前选择的值只需删除 ngModelChange 并将其添加到提交方法函数中,例如
<div class="select" >
<select class="form-control col-lg-8" #selectedValue name="selectedValue" id="selectedValue" [(ngModel)]="selectedValue[i]" >
<option *ngFor="let corporation of user_corporations" [ngValue]="corporation">{{corporation.corp_name}}</option>
</select>
<button type="submit" class="btn btn-primary manage" (click)="assignCorporationToManage(selectedValue[i])">Submit</button>
</div>