How to disable autocomplete in angular material md-autocomplete

I want to disable browser autocomplete (Chrome) feature for my md autocomplete.
I also read # 2699 , but since I don't have an input tag in my md autocomplete, I don't know where to apply type = "search"

Has anyone already achieved this?

<div class="autocomplete" flex>
            <md-icon class="icon"  md-svg-icon="user"></md-icon>

            <md-autocomplete
                    md-no-cache="ctrl.noCache"
                    md-selected-item="ctrl.selectedUserItem"
                    md-search-text-change="ctrl.searchUserTextChange(ctrl.searchText)"
                    md-search-text="ctrl.searchUserText"
                    md-selected-item-change="ctrl.selectedUserItemChange(useritem)"
                    md-items="useritem in ctrl.querySearchUsers(ctrl.searchUserText)"
                    md-item-text="useritem.Name"
                    md-min-length="0"
                    md-menu-class="autocomplete-custom-template"
                    md-floating-label="Username">
                <md-item-template>
                 <span> {{useritem.Title}} </span>
                 <span> <strong> {{useritem.Name}}</strong>, </span>
               </md-item-template>
            </md-autocomplete>
        </div>

      

+3


source to share


1 answer


Looking at the source code for 1.1.4

, autocomplete is definitely set to "off" and type is set to "search":

      return '\
        <md-input-container ng-if="floatingLabel">\
          <label>{{floatingLabel}}</label>\
          <input type="search"\
              ' + (tabindex != null ? 'tabindex="' + tabindex + '"' : '') + '\
              id="{{ inputId || \'fl-input-\' + $mdAutocompleteCtrl.id }}"\
              name="{{inputName}}"\
              autocomplete="off"\
              ...

      

If it still auto-completes, maybe you have an extension or add-on ignoring the setting?



Also, make sure it's not a caching issue. In Chrome, open developer tools (F12), go to the Network tab and check the Disable cache box (which only applies when opening dev tools) and then refresh the page.

If you are merging / minifying, make sure you recompile / republish and that the page is actually using the correct script.

+1


source







All Articles