关于angularjs+typeahead的整合

和angularjs-xeditable的基本相似,主要区别在于前者用于普通input中,后者用于xeditable中

在angularjs-xeditable需要自动提示的地方要用e-uib-typeahead和e-typeahead-on-select,而在普通页面时需要使用uib-typeahead和typeahead-on-select。

当然首先需要加入模块

var Myapp = angular.module('Myapp ',['xeditable']);

HTML代码如下

angularjs-xeditable中

        <span editable-text="product.type" e-name="type" e-form="rowform" 
         e-uib-typeahead="products.type  for products in products | filter:$viewValue | limitTo:8" 
         e-typeahead-on-select="getProductDetail($item, $model)" 
          >
           {{ product.type || 'empty' }}
        </span>

普通的input中

<input type="text" id="choseDeviceName" name="choseDeviceName" class="form-control" ng-model="selected" 
uib-typeahead="products.type  for products in products | filter:$viewValue | limitTo:8" 
typeahead-on-select="funcGetProductDetail($item, $model, $label, $event)"  
> 

 JS的数据

$http.get('selectProducts').successs(function(data){
  $scope.products=data;
})
原文地址:https://www.cnblogs.com/wangzun/p/6277321.html