AngularJS expression. If it evaluates to true, it sets the
required attribute to the element and adds the required
ngModel.NgModelController#$validators validator.
ngRequired adds the required ngModel.NgModelController#$validators validator to ngModel ngModel.
It is most often used for input input and select select controls, but can also be
applied to custom controls.
The directive sets the required attribute on the element if the AngularJS expression inside
ngRequired evaluates to true. A special directive for setting required is necessary because we
cannot use interpolation inside required. See the guide/interpolation interpolation guide
for more info.
The validator will set the required error key to true if the required attribute is set and
calling ngModel.NgModelController#$isEmpty NgModelController.$isEmpty with the
ngModel.NgModelController#$viewValue ngModel.$viewValue returns true. For example, the
$isEmpty() implementation for input[text] checks the length of the $viewValue. When developing
custom controls, $isEmpty() can be overwritten to account for a $viewValue that is not string-based.
Param: ngRequired
AngularJS expression. If it evaluates to
true
, it sets therequired
attribute to the element and adds therequired
ngModel.NgModelController#$validatorsvalidator
.ngRequired adds the required ngModel.NgModelController#$validators
validator
to ngModelngModel
. It is most often used for inputinput
and selectselect
controls, but can also be applied to custom controls.The directive sets the
required
attribute on the element if the AngularJS expression insidengRequired
evaluates to true. A special directive for settingrequired
is necessary because we cannot use interpolation insiderequired
. See the guide/interpolation interpolation guide for more info.The validator will set the
required
error key to true if therequired
attribute is set and calling ngModel.NgModelController#$isEmptyNgModelController.$isEmpty
with the ngModel.NgModelController#$viewValuengModel.$viewValue
returnstrue
. For example, the$isEmpty()
implementation forinput[text]
checks the length of the$viewValue
. When developing custom controls,$isEmpty()
can be overwritten to account for a $viewValue that is not string-based.