Reputation: 841
I'm building a component in nativescript, and I'm getting the following error "No value accessor for form control with unspecified name attribute"
I'm doing the same thing I feel I've done in other components with no problem, so I can't understand why it is not working.
First, here is the relevant code from friend.component.ts:
import { Component, ElementRef, ViewChild } from "@angular/core";
import { TextField } from "ui/text-field";
@Component({
selector: "Friends",
templateUrl: "controller/friend/friend.component.xhtml",
})
export class FriendComponent
{
friendName: string;
@ViewChild("friendNameTextField") friendNameTextField: ElementRef;
constructor() {
this.friendName = "";
}
}
And here is the code from controller/friend/friend.component.xhtml
<GridLayout rows="auto, *">
<GridLayout row="0" columns="*, auto">
<Textfield col="0" #friendNameTextField [(ngModel)]="friendName" hint="Search for friend"></Textfield>
<Label col="1" text="+ Add Friend" (tap)="addFriend()"></Label>
</GridLayout>
</GridLayout>
I read that this can happen if the NativeScriptFormsModule is not included, but I have this in app.module.ts:
import { NativeScriptFormsModule } from "nativescript-angular/forms";
@NgModule({
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule,
NativeScriptRouterModule,
NativeScriptRouterModule.forRoot(routes)
],
declarations: [
AppComponent,
...navigatableComponents,
],
bootstrap: [AppComponent],
})
export class AppModule {}
I've stripped some of the code out of this, and I'm still pretty new at Nativescript, so it's possible I've left something relevant out. Please let me know what else you need to see if I've missed something and I'll post it.
Thank you.
Upvotes: 2
Views: 2395
Reputation: 841
Solved my problem hours later.
I had:
<Textfield>
Instead of
<TextField>
There's a lesson I won't soon forget.
Upvotes: 4