Show / hide div when selecting option from a select

0

I need to make a selection of a select with a div when selecting the option.

I'm using angular, how can I do this?

    
asked by anonymous 09.08.2017 / 16:00

1 answer

2

Only use the ng-show directive.

angular.module('app', []).controller('mainController', function($scope){
  $scope.mostrarDiv = false;
  $scope.opcoes = [
    { descr: "Mostrar", valor: true },
    { descr: "Não mostrar", valor: false }
  ];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="app" ng-controller="mainController">
  <select ng-options="opcao.valor as opcao.descr for opcao in opcoes" ng-model="mostrarDiv"></select>
  
  <div ng-show="mostrarDiv">
    Alguma coisa
  </div>
</div>
    
09.08.2017 / 16:15