R
R
Roma Cockenshtuff2016-02-22 14:56:19
Angular
Roma Cockenshtuff, 2016-02-22 14:56:19

How to do select validation in angularjs?

Hello everyone, here is the select code:

<div class="form-group">
      <div class="required info ng-hide" ng-show="createForm.tag.$error.required">Required field</div>
      {!! Form::label('tags', 'Tags*:') !!}
      <select name="tags[]" id="tags" ng-model="tag" multiple="multiple" required class="form-control select2">
        @foreach($tags as $tag)
          <option label="tag" value="{{ $tag['id'] }}">{{ $tag['name'] }}</option>
        @endforeach
      </select>
    </div>

How can I validate this select without ng-options, options are apparently unloaded from the server, make an ajax request for them, somehow I don’t want it to be too hard.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Артур, 2016-02-22
@astralo

<script>window.settings.tags={!! $tags !!};</script>
<select name="tags[]" id="tags" ng-model="tag" multiple="multiple"
required class="form-control select2" ng-options="vm.tags"></select>

vm = this;
vm.tags = $window.settings.tags;

может так?
и доп запросов делать не надо

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question