Angular2 表单页面重新加载?
Angular2 form page reloads?
我正在使用 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 jQuery: any;
@组件({
选择器:'cat-page',
templateUrl: './login-alpha.html'
})
导出 class PagesLoginAlpha{
onSubmit()
{
console.log("in submittt");
}
}
将类型更改为按钮
<input type="button" class="btn btn-primary mr-3" (click)="onSubmit()" />
或使用按钮
<button type="button" (click)="onSubmit()">submit</button>
我正在使用 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 jQuery: any;
@组件({ 选择器:'cat-page', templateUrl: './login-alpha.html' })
导出 class PagesLoginAlpha{
onSubmit()
{
console.log("in submittt");
}
}
将类型更改为按钮
<input type="button" class="btn btn-primary mr-3" (click)="onSubmit()" />
或使用按钮
<button type="button" (click)="onSubmit()">submit</button>