我从服务器{status: false, message: "The Mobile Number field is required.↵"}
submitForm() {
this.createItem(this.data).subscribe((response) => {
console.log(response)
console.log(this.data)
});
}
此函数调用一个发送手机号码的函数
createItem(data): Observable<MobileNo> {
console.log(`data = ` ,JSON.stringify(data))
return this.httpClient
.post<MobileNo>(this.base_path, JSON.stringify(data), this.httpOptions)
.pipe(
retry(2),
catchError(this.handleError),
)
}
发布数据的功能
export class MobileNo {
ext : string;
mobile_no :string;
}
MobileNo Class
<div class="container">
<h3>Edit Student Data</h3>
<div class="form-group">
<label for="name">mobile</label>
<input type="number" class="form-control" #todo id="name" [(ngModel)]="data.mobile_no" placeholder="Enter No">
</div>
<div class="form-group">
<label for="age">ext</label>
<input type="number" class="form-control" id="age" [(ngModel)]="data.ext" placeholder="Enter 91">
</div>
<button type="submit" class="btn btn-success" (click)="submitForm()">Update</button>
<button type="submit" class="btn btn-warning ml-1" [routerLink]="[ '/welcome']">Cancel</button>
</div>
表格提交编号
我在这里做错了,我不知道