3
I am using the material angular, and I need a close button when I select the select, it only closes the box if you click outside, below has an example:
HTML:
<div ng-controller="MyCtrl" layout layout-align="center center">
<md-select ng-model="myModel" placeholder="Escolha" ng-change="onChange()" md-on-open="onOpen()">
<md-option value="0">Opção A</md-option>
<md-option value="1">Opção B</md-option>
<button>fechar (x)</buton>
</md-select>
</div>
Javascript:
angular.module('MyApp', ['ngMaterial'])
.controller('MyCtrl', function ($scope) {
$scope.onChange = function() {
//alert('on change');
};
$scope.onOpen = function() {
//alert('on open');
};
})
https://jsfiddle.net/samucsouza/0bsgpe1n/5/
I did it that way, but it didn’t work:
<md-button ng-click="fechar()">Botão fechar select</md-button>
$scope.fechar = function () {
$mdSelect.hide();
};
ReferenceError: $mdSelect is not defined
Hello Samuel! Could you include the code here in the question? In addition to facilitating who will help you, your question fits the rules of the OS! Any questions, take a look at help center ! Hugs!
– Thiago Luiz Domacoski
I added the answer to the "Referenceerror: $mdSelect is not defined" error in my reply below.
– Sorack