Show/hide div when selecting a select option

Asked

Viewed 355 times

0

I need to make it so that when selecting a select option a select appears div.

I’m using angular, how can I do that?

  • No code is difficult, but can use javascript

1 answer

2


Only use the directive ng-show.

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>

<div ng-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>

  • Thanks Brother helped, sorry I don’t know anything about Angular I’m starting and needed urgently, I thank you!

Browser other questions tagged

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