此表达式不可调用。类型"NgForm"没有呼叫签名



我已经创建了一个基本的注册从在角和得到这个错误

src/app/developers/signup/signup.component.html:55:45 - error:这个表达式不可调用。类型'NgForm'没有调用签名。

55

src/app/开发人员/注册/signup.component.ts: 5:16templateUrl: './sign .component.html';~~~~~~~~~~~~~~~~~~~~~~~~~SignupComponent组件模板出错

ts文件:

import { Component, OnInit } from '@angular/core';

@Component({`enter code here`
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css']
})
export class SignupComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}
developersignup()
{}
}

html文件:

<form #developersignup="ngForm" (ngSubmit)="developersignup()"   >
<table [cellPadding]="8">
<tr>
<td>Name :</td>
<td>
<input type="text" ngModel name="fullname" placeholder="enter full name">
</td>
</tr>
<tr>
<td>Email :</td>
<td>
<input type="email" ngModel name="emailaddress" placeholder="enter email address">
</td>
</tr>
<tr>
<td>Password :</td>
<td>
<input type="password" ngModel name="password" placeholder="enter password">
</td>
</tr>
<tr>
<td>Confirm Password :</td>
<td>
<input type="password" ngModel name="confirmpassword" placeholder="enter confirm password">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<button>Signup</button>
</td>
</tr>
</table>
</form>

您使用了相同的名称。e: developersignup)在你的。html文件中使用ngSubmit方法和引用变量。下行参考

<form #developersignup="ngForm" (ngSubmit)="developersignup()">

更改其中任何一个的名称,你都不会得到这个错误。

例如<form #signupForm="ngForm" (ngSubmit)="developersignup()">

试试这样做:

Html:

<form #developersignup="ngForm" (ngSubmit)="submit(developersignup)">
<!-- ... -->
</form>

ts:

submit(data : NgForm) {
console.log(data.value);
}

最新更新