AngularJSng-required
ディレクティブ
例
入力フィールドを必須にします。
Required:
<input type="checkbox" ng-model="myVar">
<input name="myInput"
ng-model="myInput" ng-required="myVar">
定義と使用法
ng-required
ディレクティブは、フォームフィールド(inputまたはtextarea)の必須属性を設定します。
ng-required
属性内の式がtrueを返す場合は、フォームフィールドが必要になります。
ディレクティブは、との間でng-required
値をシフトできるようにするために必要です。HTMLでは、属性をに設定することはできません(必須属性が存在すると、その値に関係なく、要素が必須になります)。true
false
required
false
構文
<input ng-required="expression"></input>
<input>、<select>、<textarea>およびその他の編集可能な要素でサポートされています
パラメータ値
Value | Description |
---|---|
expression | An expression that will set the required attribute if it returns true. |