2017-08-28 15 views
0

次のチェックボックスにチェックが入っていることを確認するチェックが必要です。ただし、以下は常に正常に検証されます。私はrequiredTrueニーズが使用されることを信じて、私はこのエラーを取得:ion-checkbox(テンプレート駆動型)にrequiredTrueを使用する方法

Can't bind to 'requiredTrue' since it isn't a known property of 'ion-checkbox'.

<ion-item text-wrap color="bright"> 
    <ion-label>I confirm my details are correct.</ion-label> 
    <ion-checkbox name="confirmedAccountDetails" [(ngModel)]="data.confirmedAccountDetails" #confirmedAccountDetails="ngModel" [required]="data.requiresConfirmation" ></ion-checkbox> 
    </ion-item> 

テンプレート駆動型フォームでチェックとして、私は、このチェックボックスを検証することができますどのように?

答えて

0

私の代わりにrequiredまたはrequiredTrue私が使用し

を使用するのでは、回避策を見つけた:[disabled]="!data.requiresConfirmation" pattern="true"

<ion-item text-wrap color="bright"> 
    <ion-label>I confirm my details are correct.</ion-label> 
    <ion-checkbox name="confirmedAccountDetails" [(ngModel)]="data.confirmedAccountDetails" #confirmedAccountDetails="ngModel" [disabled]="!data.requiresConfirmation" pattern="true" ></ion-checkbox> 
    </ion-item> 

これが無効になっている間、検証を防ぎ、有効にしたとき値は'true'ことを期待しています。

唯一の理由はパターン検証であり、必須ではありません。

関連する問題