Remove blank select option Angularjs

Asked

Viewed 611 times

0

Good afternoon, I need to remove the blank line that comes as default in the select of Angularjs, I would like to put a default value in place of the blank line. I researched several forums and tried many options but nothing worked. can help me?

inserir a descrição da imagem aqui

<div class="col-md-3">
    <label>SubClasse</label>
    <select ng-model="modelcompraevenda.subClasse" class="form-control">
        <option  ng-selected="data.unit == 2"  ng-selected="true"  ng-repeat="z in modelcompraevenda.listSubClasses" value="{{z.id}}">{{z.descricao}}</option>
    </select>
</div>

2 answers

1

You need to set an initial value for your model, this way:

$scope.modelcompraevenda.subClasse = $scope.modelcompraevenda.listSubClasse[0];
  • didn’t work out :/

  • 1

    your reply complements my, thank you my dear!

0


I solved it! follows solution:

<div class="col-md-3">
     <label>SubClasse</label>
     <select ng-model="modelcompraevenda.subClasse" class="form-control" style="z-index:0" ng-options="z.descricao for z in modelcompraevenda.listSubClasses track by z.id">
     </select>
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.