Select component disabled and selected angular value

Asked

Viewed 592 times

2

I have the following situation

I have a municipality select component

<div class="form-group col-md-4">
    <label>Entidade:</label> 
        <select ng-model="distrito.entidade.idEntidade" class="form-control">
            <option value="{{dis.entidade.idEntidade}}" ng-repeat="dis in distritos">{{dis.entidade.nome}}</option>
        </select>
</div>

I need this select to stay fixed with the option selected and disabled. In this case the user can see the entity but not change it.

1 answer

1


Just use the directive ng-disabled.

What your code would look like:

<div class="form-group col-md-4">
<label>Entidade:</label> 
    <select ng-disabled="true" ng-model="distrito.entidade.idEntidade" class="form-control">
        <option value="{{dis.entidade.idEntidade}}" ng-repeat="dis in distritos">{{dis.entidade.nome}}</option>
    </select>
</div>
  • did exact as you suggested but it did not work, I must also comment that is coming more than one entity in this select

  • The field remained enabled?

  • 1

    Yes, it remained enabled.

  • Really, had an error, edited fixing, see if it solves your problem.

Browser other questions tagged

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