Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
feat(select): add md-container-class for custom styling
Browse files Browse the repository at this point in the history
closes #3116
  • Loading branch information
rschmukler committed Jun 28, 2015
1 parent 16912ba commit b8897db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ angular.module('material.components.select', [
* @param {expression=} md-on-close expression to be evaluated when the select is closed
* @param {string=} placeholder Placeholder hint text.
* @param {string=} aria-label Optional label for accessibility. Only necessary if no placeholder or
* @param {string=} md-container-class class list to get applied to the .md-select-menu-container element (for custom styling)
* explicit label is present.
*
* @usage
Expand Down Expand Up @@ -336,6 +337,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $mdAria, $interpolate,
selectEl.data('$mdSelectController', mdSelectCtrl);
selectScope = scope.$new();
$mdTheming.inherit(selectContainer, element);
selectContainer[0].setAttribute('class', selectContainer[0].getAttribute('class') + ' ' + element.attr('md-container-class'));
selectContainer = $compile(selectContainer)(selectScope);
selectMenuCtrl = selectContainer.find('md-select-menu').controller('mdSelectMenu');
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/select/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ describe('<md-select>', function() {
expect(select.attr('aria-disabled')).toBe('true');
}));

it('supports passing classes to the container', inject(function($document) {
var select = setupSelect('ng-model="val", md-container-class="test"').find('md-select');
openSelect(select);
var container = $document[0].querySelector('.md-select-menu-container');
expect(container).toBeTruthy();
expect(container.classList.contains('test')).toBe(true);
}));

it('closes the menu if the element is destroyed', inject(function($document, $rootScope) {
var called = false;
$rootScope.onClose = function() {
Expand Down

0 comments on commit b8897db

Please sign in to comment.