Angular2'de en basit iki yollu bağlama yapmaya çalışıyorum. Bileşenle şablonunun arasında bir değişken paylaşmak istiyorum.Bir textarea değeri bağlama
<textarea [(ngModel)]="currentQuery"></textarea>
Ve bileşenidir:
Benim şablon
import { Component } from '@angular/core';
import { ViewChild } from '@angular/core';
import { OnInit } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'vs-home',
templateUrl: 'home.component.html'
})
export class HomeComponent {
private currentQuery: string = '';
}
Docs göre bu çalışması gerekir ama ben alıyorum:
Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'ngModel' since it isn't a known property of 'textarea'. ("
<div class="query-bar-container">
<textarea [ERROR ->][(ngModel)]="currentQuery"></textarea>
<!-- <button type="button" class="btn btn-default" (click"): [email protected]:15
bakın Ayrıca ['ngModel' öğesine 'giriş' özelliği bilinmediği için bağlanılamıyor] (http s: //stackoverflow.com/a/38896469/603003). – ComFreek