问题描述
什么是之间的差别NG-质朴
和 NG-脏
?看来你可以同时为真正
:
$ scope.myForm $质朴= TRUE; //编辑表单后,
的 NG-脏
类告诉您该表已被用户修改,而 NG-质朴
类告诉你的形式没有被用户修改。因此, NG-脏
和 NG-质朴
都是同一个故事的两个方面。
的类设置任何字段,而形式有两个属性, $脏
和 $质朴
。
您可以使用 $ scope.form。$ setPristine()
功能重置形式原始状态(请注意,这是一个AngularJS 1.1.x的功能)
如果你想,即使在AngularJS的1.0.x的分支 $ scope.form。$ setPristine()
-ish行为,您需要推出自己的解决方案(有些pretty好的,可以发现 here).基本上,这意味着在迭代所有的表单字段及其 $脏
标志设置为假
。
希望这有助于。
What are the differences between ng-pristine
and ng-dirty
? It seems you can have both to be true
:
$scope.myForm.$pristine = true; // after editing the form
The ng-dirty
class tells you that the form has been modified by the user, whereas the ng-pristine
class tells you that the form has not been modified by the user. So ng-dirty
and ng-pristine
are two sides of the same story.
The classes are set on any field, while the form has two properties, $dirty
and $pristine
.
You can use the $scope.form.$setPristine()
function to reset a form to pristine state (please note that this is an AngularJS 1.1.x feature).
If you want a $scope.form.$setPristine()
-ish behavior even in 1.0.x branch of AngularJS, you need to roll your own solution (some pretty good ones can be found here). Basically, this means iterating over all form fields and setting their $dirty
flag to false
.
Hope this helps.
这篇关于在AngularJS,什么是NG-原始和NG-脏之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!