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

Commit 2a83967

Browse files
VictorioBerrajosephperrott
authored andcommitted
feat(autocomplete): add md-input-class binding. (#11102)
1 parent 52a2e10 commit 2a83967

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/components/autocomplete/autocomplete.spec.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,27 @@ describe('<md-autocomplete>', function() {
351351
element.remove();
352352
}));
353353

354+
it('forwards the `md-input-class` attribute to the input', function() {
355+
var scope = createScope(null, {inputClass: 'custom-input-class'});
356+
var template = '\
357+
<md-autocomplete\
358+
md-floating-label="Some Label"\
359+
md-input-class="{{inputClass}}"\
360+
md-selected-item="selectedItem"\
361+
md-search-text="searchText"\
362+
md-items="item in match(searchText)"\
363+
md-item-text="item.display"\
364+
placeholder="placeholder">\
365+
<span md-highlight-text="searchText">{{item.display}}</span>\
366+
</md-autocomplete>';
367+
var element = compile(template, scope);
368+
var input = element.find('input');
369+
370+
expect(input).toHaveClass(scope.inputClass);
371+
372+
element.remove();
373+
});
374+
354375
it('forwards the `md-select-on-focus` attribute to the input', inject(function() {
355376
var scope = createScope(null, {inputId: 'custom-input-id'});
356377
var template =

src/components/autocomplete/js/autocompleteDirective.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ angular
107107
* `md-input-container`.
108108
* @param {string=} md-input-name The name attribute given to the input element to be used with
109109
* FormController.
110+
* @param {string=} md-menu-class This will be applied to the dropdown menu for styling
111+
* @param {string=} md-input-class This will be applied to the input for styling. This attribute is only valid when a `md-floating-label` is defined
112+
* @param {string=} md-floating-label This will add a floating label to autocomplete and wrap it in
113+
* `md-input-container`
114+
* @param {string=} md-input-name The name attribute given to the input element to be used with
115+
* FormController
110116
* @param {string=} md-select-on-focus When present the inputs text will be automatically selected
111117
* on focus.
112118
* @param {string=} md-input-id An ID to be added to the input element.
@@ -250,6 +256,7 @@ function MdAutocomplete ($$mdSvgRegistry) {
250256
floatingLabel: '@?mdFloatingLabel',
251257
autoselect: '=?mdAutoselect',
252258
menuClass: '@?mdMenuClass',
259+
inputClass: '@?mdInputClass',
253260
inputId: '@?mdInputId',
254261
escapeOptions: '@?mdEscapeOptions',
255262
dropdownItems: '=?mdDropdownItems',
@@ -354,6 +361,7 @@ function MdAutocomplete ($$mdSvgRegistry) {
354361
' + (tabindex != null ? 'tabindex="' + tabindex + '"' : '') + '\
355362
id="{{ inputId || \'fl-input-\' + $mdAutocompleteCtrl.id }}"\
356363
name="{{inputName}}"\
364+
ng-class="::inputClass"\
357365
autocomplete="off"\
358366
ng-required="$mdAutocompleteCtrl.isRequired"\
359367
ng-readonly="$mdAutocompleteCtrl.isReadonly"\
@@ -380,6 +388,7 @@ function MdAutocomplete ($$mdSvgRegistry) {
380388
' + (tabindex != null ? 'tabindex="' + tabindex + '"' : '') + '\
381389
id="{{ inputId || \'input-\' + $mdAutocompleteCtrl.id }}"\
382390
name="{{inputName}}"\
391+
ng-class="::inputClass"\
383392
ng-if="!floatingLabel"\
384393
autocomplete="off"\
385394
ng-required="$mdAutocompleteCtrl.isRequired"\

0 commit comments

Comments
 (0)