$scope.form.$setPristine() を使用すると、undefined が返されます。
<html>
<form name="my_form">
...
</form></html>
$routeProvider でコントローラーを定義する
.when('page_name', {
templateUrl: '...',
controller: function($scope) {
console.log(my_form); // returns the form object
my_form.$setPristine(); returns Object #<HTMLFormElement> has no method '$setPristine'
console.log($scope.my_form); // returns undefined
$scope.my_form.$setPristine(); // returns Cannot call method '$setPristine' of undefined
}
}
また、フォームを jQuery 経由で $scope に渡そうとしましたが$scope.my_form = $('form');
、予想どおり、フォーム オブジェクトを送信したところ、最初のエラーが発生しました。この方法を機能させるには何が必要ですか?
デモ用にプランカーをまとめてみましたが、ルーティングを適切に動作させることができないようです。
ところで、フォームに関する他のすべてが機能します。$setPristine を機能させる方法を知りたいだけです。