1
入力フィールドにバインドされているngControlの角度オブジェクトをconsoleに記録するだけで、その内容を見ることができます。以下はngControlの非常に基本的な例ですが、動作するはずですが、コンソールにログオンしようとすると定義されません。ngControlの結果が未定義
誰かがこれに遭遇しましたか?私は解決の助けに感謝します。
アプリケーションコンポーネント
import {Component} from 'angular2/core';
import {ContactFormComponent} from './contact-form.component';
@Component({
selector: 'my-app',
directives: [ContactFormComponent],
template: '<contact-form></contact-form>',
})
export class AppComponent {
}
問い合わせフォームテンプレート
import {Component, Input} from 'angular2/core';
@Component({
selector: 'contact-form',
templateUrl: 'app/contact-form.component.html'
})
export class ContactFormComponent{
log(x) {
console.log(x);
}
}
フォームテンプレート
<form>
<div class="form-group">
<label for="firstName">First Name</label>
<input ngControl="firstName" #firstName="ngForm" (change)="log()" id="firstName" type="text" class="form-control">
</div>
<div class="form-group">
<label for="comment">
Comment
</label>
<textarea ngControl="comment" #comment="ngForm" (change)="log()" id="comment" cols="30" rows="10" class="form-control">
</textarea>
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</form>
私は/あなたがFormsModuleまたは@角度のどの部分をインポート表示されませんそのディレクトリを使用できるようにするフォーム息をする。 FormsModuleをインポートするNgModuleがありますか? – gelliott181
私はそれをインポートしないで、彼のために働くように見えるので、私はそれがそのRCに必要ではないと仮定しているステップごとにビデオチュートリアルに従っていますか?メモ、彼はチュートリアルの後半まで最新のRCに更新されません - それは彼のために働くようです – AnchovyLegend
公式フォームチュートリアル(https://angular.io/docs/ts/latest/guide /forms.html)。 RCバージョンは広範な変更点で非常に速いペースであり、これらのプレリリースバージョンを使用するプロジェクトは、最新のAngularリリースを使用して完全に動作する可能性は低いです。 – gelliott181