Answer the question
In order to leave comments, you need to log in
How to serialize form in angular for $http?
I have inputs in the form that are generated on the fly, so I can’t just bandage them with ng-model + I would like not to write too much, but to do everything elegantly and beautifully, as it is done in jquery. In general, the point is, how to just take a form and serialize it, or how to take ajax from jquery and implement it in angular?
PS: this is not the first disappointment in angular, during the time that I wrote the request I could write native xmlHttpRequest requests of 10 pieces probably, maybe I can’t catch up with the chips, if it’s not difficult to remember, throw off some resources that open your eyes to the masterpiece of angular
{!! Form::model($article, ['method' => 'PATCH', 'action' => ['[email protected]', $article->id], 'ng-controller' => 'editFormController', 'name' => 'editForm', 'class' => "rg-form", 'ng-submit' => 'editTheArticle($event, ' . $article->id . ')']) !!}
<div class="form-group">
<div class="required info ng-hide" ng-show="editForm.title.$error.required">Required field</div>
<div class="required ng-hide" ng-show="editForm.title.$error.minlength && editForm.title.$dirty">Must be at least 3 simbols long</div>
<div class="required ng-hide" ng-show="editForm.title.$error.maxlength && editForm.title.$dirty">Can't be more than 250 simbols</div>
{!! Form::label('title', 'Title*:') !!}
{!! Form::text('title', null, ['class' => 'form-control',
'ng-model' => "title",
'required',
'ng-minlength' => '3',
'ng-maxlength' => '250',
'use-form-data'
]) !!}
</div>
<div class="form-group">
<div class="required info ng-hide" ng-show="editForm.body.$error.required">Required field</div>
<div class="required ng-hide" ng-show="editForm.body.$error.minlength && editForm.body.$dirty">Must be at least 400 simbols long</div>
{!! Form::label('body', 'Body*:') !!}
{!! Form::textarea('body', null, ['class' => 'form-control',
'ng-model' => 'body',
'required',
'ng-minlength' => '400',
'use-form-data'
]) !!}
</div>
<div class="form-group">
{!! Form::label('tags', 'Tags:') !!}
{!! Form::select('tags[]', \App\Tag::lists('name', 'id'), $article->tags()->lists('id')->toArray(), ['class' => 'form-control select2', 'multiple' => 'multiple']) !!}
</div>
<div class="form-group">
{!! Form::submit('Edit', ['class' => 'btn btn-primary form-control',
'ng-disabled' => 'editForm.$invalid'
]) !!}
</div>
{!! Form::close() !!}
Answer the question
In order to leave comments, you need to log in
I can't just bandage them with ng-model
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question