表格在角度4中有效(全部验证)后关闭弹出模式

时间:2018-08-10 08:57:34

标签: html angular angular4-forms

我们使用html形式的data-dismiss正常工作。但是每次单击“提交”按钮天气表单有效或无效时,模式关闭

HTML代码

<form #AddAirlineuser="ngForm">
    <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">CREATE PROFILE</h4>
    </div>
    <div class="modal-body">
        <label>Name</label>
        <p><input type="text" name="name" class="form-control" aria-label="..." ngModel></p>
        <label>Email</label>
        <p><input type="text" name="email" class="form-control" aria-label="..." ngModel></p>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Delete</button>
        <button type="submit" class="btn btn-primary" (click) = "Btn_AddNewAirline(AddAirlineuser.valid,AddAirlineuser.value)">Submit</button>
    </div>
</form>

TypeScript代码

Btn_AddNewAirline(formstatus: any,data:any){
    let AirlineData: any = {
        name: data.name,
        email: data.email
    };
    if(formstatus){
        // TODO code form status is valid 
    }
}

0 个答案:

没有答案