【发布时间】:2020-09-20 22:50:06
【问题描述】:
我正在开发带有 Angular 应用程序的 Nativescript,我在其中创建了一个表单,以便用户能够使用表单添加新记录。该应用程序正在使用 REST API 在数据库上创建新记录。这是我得到的错误
newContact(){
this.contactservices.submitContact(this.postContact).subscribe(
result => this.router.navigate(["/home"]),
error => console.error(error)
)
}
headers = new HttpHeaders({
"Content-Type": "application/json",
Authorization: "Token 5a72afc446dd4c38e5"
});
constructor(private http: HttpClient) { }
submitContact(opost: ContactData){
return this.http.post(this.url, opost, {headers: this.headers})
}
<StackLayout >
<TextField hint="Your First Name" [(ngModel)]="postContact.first_name" #element></TextField>
<TextField hint="Your Last Name" [(ngModel)]="postContact.last_name" #element></TextField>
<TextField hint="Your Email" [(ngModel)]="postContact.email" #element></TextField>
<TextView hint="Type your message here" [(ngModel)]="postContact.message" #element></TextView>
</StackLayout>
<FlexboxLayout class="about-button" alignItems="center">
<Button class="btnBack" text="Back"></Button>
<Button class="btnSend" text ="Send" (tap)="newContact()"></Button>
</FlexboxLayout>
【问题讨论】:
标签: angular nativescript