2016-10-22 9 views
0

私はnativescriptでコンポーネントを構築しています、と私は次のエラーNativescriptエラー:未指定のname属性

I「未指定のname属性を持つフォームコントロールなし値アクセサ」を取得していますと、フォームコントロールの値なしアクセサ同じことをやっている私は他のコンポーネントで何の問題もないと思っています。なぜそれが動作しないのか理解できません。

まず、ここ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 = ""; 
    } 
} 

そして、ここで私がいることを読んで/ 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> 

コントローラ/友人からのコードですNativeScriptFormsModuleが含まれていない場合に発生することができますが、私は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 {} 

私はしましたこのコードからいくつかのコードを取り除きました。私はまだNativescriptでかなり新しいので、関連するものを残しておくことも可能です。私が何かを見逃して、私がそれを掲示する場合、あなたが見なければならない他のものを私に教えてください。

ありがとうございます。

答えて

2

時間後に解決しました。

私が持っていた:

<Textfield> 

代わりの

<TextField> 

私はすぐに忘れないだろうレッスンがありますが。

関連する問題