"Select"というデフォルト値を持つselect countryドロップダウンがあります。ドロップダウンにいくつかの国の値がある場合にのみ有効になるように、ページの下部に送信ボタンがあります。デフォルト値の場合、ボタンは必須フィールドとして無効にする必要があります。角度2のデフォルトのドロップダウン値の送信ボタンを無効にするフォーム
私の.tsファイルのドロップダウンのコンポーネントを作成しました。
@component({
selector:'country-component',
template:'<form>
<select>
<option [disabled]="butDisabled">Select</option>
<option [value]="" *ngFor="let country of countryList">{{country.label}}</option>
</select>
</form>'
})
export class countryComponent implements onInit{
butDisabled: boolean = true;
}
私のHTML-で
<country-component (ngModelOptions)="{standalone:true}" name=""></country-component>
<button>Submit</button>
これはwork.Itは全体のドロップダウンが無効になりません。私が間違っている場所を誰にでも教えてもらえますか?
ボタンの定義はどこですか?私は2つの選択肢を見る。 –
@John Baird更新されたコードを参照してください。 –