【发布时间】:2023-03-30 08:10:01
【问题描述】:
按 Enter 键需要以 Angular 4 提交表单
下面是我的Action = "" 形式的代码不起作用。
我也试过(keydown) = domonething(event)和(keydown.enter) = domonething(event)
用下面的代码
keyDownFunction(event) {
if (event.keyCode == 13) {
this.submit();
}
}
下面是我当前的代码
<form #f="ngForm" (ngSubmit)="f.form.valid && openModal(confirmationmodal)" novalidate action="">
<div class="form-group form-row">
<label class="col-form-label col-sm-4 col-md-4" for="name">Employee Name</label>
<div class="col-sm-8 col-md-8">
<span type="text" readonly class="form-control-plaintext" id="name">{{employeeDetails.EmployeeName}}</span>
</div>
</div>
<div class="form-group form-row">
<label class="col-form-label col-sm-4 col-md-4 " for="name">Manager Name</label>
<div class="col-md-8 col-sm-8">
<span type="text" readonly class="form-control-plaintext"
id="manager">{{employeeDetails.ManagerName}}</span>
</div>
</div>
<div class="form-group form-row">
<label for="name" class="col-sm-4 col-md-4 col-form-label">Subject</label>
<div class="col-md-8 col-sm-8">
<span type="text" readonly class="form-control-plaintext" id="manager">{{subject}}</span>
</div>
</div>
<button class="btn btn-success float-right" type="submit" id="submit">Submit</button>
</form>
【问题讨论】:
-
上面的评论也是上面那个的重复