json2021 json2021 - 1 year ago 53
AngularJS Question

Why does angular keep showing false when input is touched?

I am new to angular. I have set up the following code to see if an input field has been touched. However when i type on the input field. It doesn't change. Just keeps showing false.

Not sure what I am doing wrong here. Any help would be really appreciated it.

<div ng-app='myApp' ng-form name="myForm">

<input type='text' name='address' ng-model="address" id='address'>

<h1> {{myForm.address.$touched}}</h1>



var app = angular.module("myApp",[]);


Ven Ven
Answer Source

$touched in AngularJS jargon doesn't mean "was the value changed". That's $dirty's role.

$touched in AngularJS means that the field was blurred (that is, the field isn't selected anymore).

See it in action at plnkr.co.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download