Hello, is there a simple way to disable validation while an ajax request is downloading the model from the server?
Let's say I have this input.
<input type="text" class="form-control" id="FieldName" name="FieldName"
ng-model="model.thefield" required ng-maxlength="100">
And this model which does not pass the validation initially:
$scope.model = {}
So, the input is invalid until the request finishes:
$http.get('/some/url')
.then(function (response) {
$scope.model = response.data;
});
Is there a way to disable validation until this request has finished. I currently set the model to a valid value initially. Example:
$scope.model = {
thefield: "loading"
}
You can try to change your required
to ng-required="yourBool"
and then write
$http.get('/some/url')
.then(function (response) {
$scope.yourBool = true;
$scope.model = response.data;
});