非常に単純ですが、私はスティングを含むコンポーネントを持っています入力フィールドの角度2片方向データバインディング
この文字列を入力フィールドに表示する必要があります。
私はこれが好きだと思ったが、うまくいかなかった。
// Component
import {Component} from "@angular/core";
@Component({
selector: 'my-component',
templateUrl: './my-compoent.template.html';
})
export class MyComponent{
constructor(){
}
myVar: string = "Hello World"
}
// HTML
<input type="text" ([ngModel])="myVar" >
使っ '[(ngModel)] = "myVarに"'(または '[ngModel] = "myVarに"'それはちょうど1ウェイ結合されている場合) – amal
真のあなたのngModel構文が間違っ –
'[ngModel] =」でありますmyVar "'は動作しません – ttmt