top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What are different Angular form properties?

0 votes
292 views
What are different Angular form properties?
posted Nov 3, 2017 by Sathaybama

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Angular provides properties on form which help you to get information about a form or its inputs and to
validate them.
$valid - It is a boolean property that tells whether the form or it's inputs are valid or not. If all containing form and
controls are valid, then it will be true, otherwise it will be false.
Syntax

formName.$valid
formName.inputFieldName.$valid

$invalid - It is a boolean property that tells whether the form or it's inputs are invalid or not. If at least one
containing form and control is invalid then it will be true, otherwise it will be false.
Syntax

formName.$invalid
formName.inputFieldName.$invalid

$pristine - It is a boolean property that tells whether the form or it's inputs are unmodified by the user or not. If
the form or its inputs are unmodified by the user, then it will be true, otherwise it will be false.
Syntax

formName.inputFieldName.$pristine

$dirty - It is a boolean property that is actually just reverse of pristine i.e. it tells whether the form or it's inputs
are modified by the user or not. If the form or its inputs are modified by the user, then it will be true, otherwise it
will be false.
Syntax

formName.$dirty
formName.inputFieldName.$dirty

$error - This is an object hash which contains references to all invalid controls or forms. It has all errors as keys:
where keys are validation tokens (such as required, url or email) and values are arrays of controls or forms that
are invalid with given error. For a control, if a validation fails then it will be true, otherwise it will be false.
Syntax

formName.$error
formName.inputFieldName.$error
answer Nov 3, 2017 by Shivaranjini
...