Remove blank option select option angularjs

0

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

<divclass="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>
    
asked by anonymous 10.10.2017 / 20:44

2 answers

0

I was able to solve it !! follows the 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>
    
10.10.2017 / 21:30
1

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

$scope.modelcompraevenda.subClasse = $scope.modelcompraevenda.listSubClasse[0];
    
10.10.2017 / 21:15