输入提交空,使用本机脚本



我想注册用户,但我的输入值为空:

我一步一步地遵循此代码。我在代码中看不到任何问题。请问有什么想法吗?

组件.html

<GridLayout backgroundColor="#CCCCCC">
<ScrollView>
<StackLayout margin="10" verticalAlignment="center">
<StackLayout class="form" padding="15" backgroundColor="#FFFFFF">
<StackLayout class="input-field">
<Label text="First Name" class="label font-weight-bold m-b-5"></Label>
<TextField class="input" value="input.firstname"></TextField>
<StackLayout class="hr-light"></StackLayout>
</StackLayout>
<StackLayout class="input-field">
<Label text="Last Name" class="label font-weight-bold m-b-5"></Label>
<TextField class="input" [(ngModel)]="input.lastname"></TextField>
<StackLayout class="hr-light"></StackLayout>
</StackLayout>
<StackLayout class="input-field">
<Label text="Email" class="label font-weight-bold m-b-5"></Label>
<TextField class="input" [(ngModel)]="input.email"></TextField>
<StackLayout class="hr-light"></StackLayout>
</StackLayout>
<StackLayout class="input-field">
<Label text="Password" class="label font-weight-bold m-b-5"></Label>
<TextField  secure="true" [(ngModel)]="input.password" class="input" required></TextField>
<StackLayout class="hr-light"></StackLayout>
</StackLayout>
<Button class="btn btn-primary w-full" text="Register" (tap)="register()"></Button>
</StackLayout>
</StackLayout>
</ScrollView>
</GridLayout>

组件.ts

export class RegisterComponent {
public input: any;
public constructor(private location: Location) {
this.input = {
"firstname": "",
"lastname": "",
"email": "",
"password": ""
}
}
public register() {
if(this.input.firstname && this.input.lastname && this.input.email && this.input.password) {
ApplicationSettings.setString("account", JSON.stringify(this.input));
this.location.back();
} else {
(new SnackBar()).simple("All Fields Required!");
}
}}

我不明白为什么我的值提交为空!!你能问我任何想法吗?

要启用双向绑定,请检查是否在相关模块中导入NativeScriptFormsModule。如果您的应用程序没有使用延迟加载,这应该是主要app.module.ts

// Uncomment and add to NgModule imports if you need to use two-way binding
import { NativeScriptFormsModule } from "nativescript-angular/forms";
imports: [
NativeScriptFormsModule // ADD it to imports
],

请注意,您共享的代码仅在应用程序设置中保存一个键值,稍后应重用以登录用户(通过访问特定的键account

相关内容

  • 没有找到相关文章

最新更新