将其转换为提交函数

时间:2017-10-03 06:25:07

标签: angular angular-services angular-forms

如何使此表单能够提交它的功能。目前,我选择该选项并自动更改数据。我希望在更改发生之前先单击提交按钮。

<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>

1 个答案:

答案 0 :(得分:0)

我假设在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>