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

Commit 5e043a1

Browse files
devversionThomasBurleson
authored andcommitted
feat(autocomplete): allow disabling asterisk on floating label
Closes #7119
1 parent 6d705b9 commit 5e043a1

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/components/autocomplete/autocomplete.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,25 @@ describe('<md-autocomplete>', function() {
10611061
expect(ctrl.isRequired).toBe(true);
10621062
});
10631063

1064+
it('should forward the md-no-asterisk attribute', function() {
1065+
var scope = createScope();
1066+
var template = '\
1067+
<md-autocomplete\
1068+
md-selected-item="selectedItem"\
1069+
md-search-text="searchText"\
1070+
md-items="item in match(searchText)"\
1071+
md-item-text="item.display"\
1072+
md-min-length="0" \
1073+
required\
1074+
md-no-asterisk="true"\
1075+
md-floating-label="Asterisk Label">\
1076+
<span md-highlight-text="searchText">{{item.display}}</span>\
1077+
</md-autocomplete>';
1078+
var element = compile(template, scope);
1079+
var input = element.find('input');
1080+
1081+
expect(input.attr('md-no-asterisk')).toBe('true');
1082+
});
10641083
});
10651084

10661085
describe('md-highlight-text', function() {

src/components/autocomplete/js/autocompleteDirective.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ angular
5252
* @param {boolean=} md-autofocus If true, the autocomplete will be automatically focused when a `$mdDialog`,
5353
* `$mdBottomsheet` or `$mdSidenav`, which contains the autocomplete, is opening. <br/><br/>
5454
* Also the autocomplete will immediately focus the input element.
55+
* @param {boolean=} md-no-asterisk When present, asterisk will not be appended to the floating label
5556
* @param {boolean=} md-autoselect If true, the first item will be selected by default
5657
* @param {string=} md-menu-class This will be applied to the dropdown menu for styling
5758
* @param {string=} md-floating-label This will add a floating label to autocomplete and wrap it in
@@ -244,6 +245,7 @@ function MdAutocomplete () {
244245
ng-model="$mdAutocompleteCtrl.scope.searchText"\
245246
ng-keydown="$mdAutocompleteCtrl.keydown($event)"\
246247
ng-blur="$mdAutocompleteCtrl.blur()"\
248+
' + (attr.mdNoAsterisk != null ? 'md-no-asterisk="' + attr.mdNoAsterisk + '"' : '') + '\
247249
ng-focus="$mdAutocompleteCtrl.focus()"\
248250
aria-owns="ul-{{$mdAutocompleteCtrl.id}}"\
249251
' + (attr.mdSelectOnFocus != null ? 'md-select-on-focus=""' : '') + '\

0 commit comments

Comments
 (0)