I already saw questions like, How to set a particular field in a form to dirty in angularjs 1.3 and Angular.js programmatically setting a form field to dirty but they are not working.
I am auto-filling a text box in angularjs as:
$scope.address.city = "Santa Clara";
$scope.address.city.$dirty = true;
And in the html I have ng-model="address.city" ng-model-options="{ updateOn: 'change blur' }"
.
However, $scope.address.city.$dirty = true;
is giving undefined in the console.
I have used
$http.get("somewebsite.com").success(function(data){ $timeout(function () {
$scope.address.city.$dirty = true;
}, 0);
console.log('$scope.address.city.$dirty',$scope.address.city.$dirty);})
but still I am getting error as TypeError: Cannot set property '$dirty' of undefined
I am using angular 1.3.1 .