How to make an autocomplete just like google auto suggest in angular ui-select

Deadly 提交于 2019-11-30 15:37:29

there are a bower plugin autocompletelikegoogle and you can create an angular directive to render an autocomplete input in your application.

Directive.js

angular.module('app').directive('autoComplete', [
  '$timeout', function($timeout) {
    return function(scope, element, attrs) {
      var auto;
      auto = function() {
        $timeout((function() {
          if (!scope[attrs.uiItems]) {
            auto();
          } else {
            element.autocomplete({
              source: [scope[attrs.uiItems]]
            });
          }
        }), 5);
      };
      return auto();
    };
  }
]);

HTML use example

<input type="text" auto-complete ui-items="list" ng-model="yourModel" class="form-control" placeholder="Tipe something" />

The variable list contains an array of your possible results in autocomplete input, is set in the atribute called ui-items.

Use angular-ui select library...It will make REST call to get data from backend systems for autocomplete dropdown....and for watermark..You can change it through CSS. for library please find URL:https://github.com/angular-ui/ui-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!