Вопрос

I am creating a ticketing system and have several LARGE forms (it is built as a SharePoint App but that isn't germane to my question because I am using REST).

Since any form entered can also be edited, is it best practice to continue to use data binding and have to harvest ALL of the fields before submitting or could I somehow just determine which fields where changed and only update those?

I am just learning about Angular Forms and all of the examples have 2 or 3 fields. I have one form that has 58 fields which is a lot of form.lastName = $scope.lastName; coding.

Это было полезно?

Решение

angularjs does that for you. It keeps track of the original state of the model and compares against it; that is how it generate $watch events and model updates. ngForm validation that allows you to figure out which field has changed, each field in your model will have $dirty property.

Just add this css to your application to display the view.

.ng-pristine { border:1px solid Gold; }
.ng-dirty.ng-valid { border:1px solid Green; }
.ng-dirty.ng-invalid { border:1px solid Red; }
.ng-dirty.ng-valid ~ span.ok { color:green; display:inline; }
.ng-dirty.ng-invalid ~ span.ko { color:red; display:inline; }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top