massautocomplete.js
function _attach(ngmodel, target_element, options) {
        // Element is already attached.
        if (current_element === target_element) {
          return;
        }

        // Safe: clear previously attached elements.
        if (current_element) {
          that.detach();
        }

        // The element is still the active element.
        if (target_element[0] !== $document[0].activeElement) {
          return;
        }

        if (options.on_attach) {
          options.on_attach();
        }

        current_element = target_element;
        current_model = ngmodel;
        current_options = options;
        previous_value = ngmodel.$viewValue;
        current_element_random_id_set = ensure_element_id(target_element);
        $scope.container[0].setAttribute('aria-labelledby', current_element.id);

        $scope.results = [];
        $scope.selected_index = -1;
        bind_element();

        value_watch = $scope.$watch(
          function() {
            return ngmodel.$modelValue;
          },
          function(nv) {
            // Prevent suggestion cycle when the value is the last value selected.
            // When selecting from the menu the ng-model is updated and this watch
            // is triggered. This causes another suggestion cycle that will provide as
            // suggestion the value that is currently selected - this is unnecessary.
            if (nv === last_selected_value) {
              return;
            }

            _position_autocomplete();
            suggest(nv, current_element);
          }
        );
      }
function _attach(ngmodel, target_element, options) {
        // Element is already attached.
        if (current_element === target_element) {
          return;
        }

        // Safe: clear previously attached elements.
        if (current_element) {
          that.detach();
        }

        // The element is still the active element.
        if (target_element[0] !== $document[0].activeElement) {
          return;
        }

        if (options.on_attach) {
          options.on_attach();
        }

        current_element = target_element;
        current_model = ngmodel;
        current_options = options;
        previous_value = ngmodel.$viewValue;
        current_element_random_id_set = ensure_element_id(target_element);
        $scope.container[0].setAttribute('aria-labelledby', current_element.id);

        $scope.results = [];
        $scope.selected_index = -1;
        bind_element();

        value_watch = $scope.$watch(
          function() {
            return ngmodel.$modelValue;
          },
          function(nv) {
            // Prevent suggestion cycle when the value is the last value selected.
            // When selecting from the menu the ng-model is updated and this watch
            // is triggered. This causes another suggestion cycle that will provide as
            // suggestion the value that is currently selected - this is unnecessary.
            if (nv === last_selected_value) {
              return;
            }

            _position_autocomplete();
            suggest(nv, current_element);
          }
        );
      }
function _attach ( ngmodel , target_element , options ) { // Element is already attached. if ( current_element === target_element ) { return ; } // Safe: clear previously attached elements. if ( current_element ) { that . detach ( ) ; } // The element is still the active element. if ( target_element [ 0 ] !== $document [ 0 ] . activeElement ) { return ; } if ( options . on_attach ) { options . on_attach ( ) ; } current_element = target_element ; current_model = ngmodel ; current_options = options ; previous_value = ngmodel . $viewValue ; current_element_random_id_set = ensure_element_id ( target_element ) ; $scope . container [ 0 ] . setAttribute ( 'aria-labelledby' , current_element . id ) ; $scope . results = [ ] ; $scope . selected_index = - 1 ; bind_element ( ) ; value_watch = $scope . $watch ( function ( ) { return ngmodel . $modelValue ; } , function ( nv ) { // Prevent suggestion cycle when the value is the last value selected. // When selecting from the menu the ng-model is updated and this watch // is triggered. This causes another suggestion cycle that will provide as // suggestion the value that is currently selected - this is unnecessary. if ( nv === last_selected_value ) { return ; } _position_autocomplete ( ) ; suggest ( nv , current_element ) ; } ) ; }
Attach autocomplete behavior to an input element.
Attach autocomplete behavior to an input element .