我正在使用Angular2
无法弄清楚为什么页面会引用:
我的表格:
<form>
<div class="form-group">
<label class="form-label">Username</label>
<input type="email" class="form-control" id="username" placeholder="Email" name="username" />
</div>
<div class="form-group">
<label class="form-label">Password</label>
<input type="password" class="form-control" id="password" placeholder="Password" name="password" />
</div>
<input type="submit" class="btn btn-primary mr-3" (click)=onSubmit() />
</form>
在Ts:
import { Component} from '@angular/core';
声明var $:any; 声明var jQuery:any;
@Component({ 选择器:'cat-page', templateUrl:'。/ login -alpha.html' })
导出类PagesLoginAlpha {
onSubmit()
{
console.log("in submittt");
}
}
答案 0 :(得分:2)
将类型更改为按钮
<input type="button" class="btn btn-primary mr-3" (click)="onSubmit()" />
或使用按钮
<button type="button" (click)="onSubmit()">submit</button>