form入力を属性付きのに入れ、入力にname属性を与えると、入力のプロパティnameにもアクセスできます。$pristine
<div ng-controller="MyController">
<form name="myForm">
<input type="text" name="first" ng-model="firstName">
<input type="text" name="last" ng-model="lastName">
</form>
</div>
app.controller('MyController', function($scope) {
// Here you have access to the inputs' `$pristine` property
console.log($scope.myForm.first.$pristine);
console.log($scope.myForm.last.$pristine);
});
を使用して、フィールドが変更された$scope.myForm.$pristineかどうか$pristineを確認したり、フォームの各入力のプロパティのプロパティを使用して、その入力が変更されたかどうかを確認したりできます。オブジェクトを反復処理することもできmyFormます (入力フィールド以外のオブジェクトには、キーの前に が付きます$)。
angular.forEach($scope.myForm, function(value, key) {
if(key[0] == '$') return;
console.log(key, value.$pristine)
});
// first, true
// last, false