vostotskiy2016-12-20 14:18:16
vostotskiy, 2016-12-20 14:18:16

AngularJS - Why doesn't initialized field pass validator?

Hello. As a result of populating fields with an asynchronous request of form fields, several fields return a required error on submit (fields are filled with the correct data)
Form field (using mdp-datepicker with Material Design interface)

<mdp-date-picker mdp-placeholder="Date *" mdp-format="dd, MMM DD, YYYY" mdp-open-on-click required
                        <div ng-messages="vm.editForm.Date.$error" ng-if='vm.editForm.Date.$dirty'>
                            <div ng-message="required" style="color:red">Date is required</div>

When the controller is initialized, the correct data enters the form and is correctly displayed in the corresponding input.
This fragment returns false for the given field, in particular, we are talking about required
//код обработки формы

Previously, everything worked fine as long as the method for getting data from the server was located in the body of the controller. Moved the data acquisition logic to the factory and got this error. Tell me, please, in which direction to dig.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question