Angular-UI自动完成输入框AutoComplete[项目中使用]
来源:互联网 发布:阿里云怎么安装软件 编辑:程序博客网 时间:2024/06/05 06:32
一、效果展示
二、代码参考
【view视图】
<input id="countryCode" class="control-input" autocomplete="off" name="countryCode" type="text" data-ng-model="anomalieSearchPayId" placeholder="Saisir au moins 2 caractères" typeahead="country.countryCode+' - '+country.libellePay for country in getCountrys($viewValue)"typeahead-loading="loadingCountrys" typeahead-append-to-body="false" typeahead-min-length="2"ypeahead-template-url="countryTemplate.html" typeahead-editable="false" typeahead-on-select="onChangeCountrys($item, $model, $label)"class="form-control" required="required" /><i data-ng-show="loadingCountrys" class="glyphicon glyphicon-refresh"></i>
<script type="text/ng-template" id="countryTemplate.html"><a tabindex="-1"><span bind-html-unsafe="match.label | typeaheadHighlight:query"></span></a></script>
【控制器部分】
$scope.getCountrys=function(searchText){return CountryService.getCountrysBySearchText(searchText).$promise.then(function(data) { return data; }); };$scope.onChangeCountrys=function(item, model, label){ $scope.anomalieSearch.payId= item.countryCode; };$scope.$watch('anomalieSearchPayId',function (newValue, oldValue, scope){ if(!newValue){ $scope.anomalieSearch.payId=""; } });
【service部分】
define(['angular'], function (angular) { var CountryManagement = angular.module('CountryManagement', ['ui.bootstrap']); CountryManagement.factory('CountryService', [ '$resource', '$log', function ($resource, $log) { var Country = $resource('rest/countrys/:verb' , { verb:'@verb'}, { }); return { allCountrys: function (state) { return Country.query({ state: state }); }, getMissionCountrys: function (externFamId) { return Country.query({ verb:"getMissionCountrys",externFamId:externFamId }); }, getCountrysBySearchText: function (searchText) { return Country.query({ verb:"getCountrysBySearchText", searchText: searchText }); } }; }]); CountryManagement.controller('CountryManagementController', ['$scope','$timeout', 'CountryService', '$location', function ($scope,$timeout, CountryService, $location) { }]); return { angularModules: [ 'CountryManagement' ] };});
【后台逻辑】
1、访问入口
@GET @Path("/getCountrysBySearchText") @Produces(MediaType.APPLICATION_JSON) @RequiresPermissions(value = { "gedex:company:search", "gedex:company:create", "gedex:company:update", "gedex:trace:trace", "gedex:mission:create" }, logical = Logical.OR) public Response getCountrysBySearchText(@QueryParam("searchText") String searchText) { LOG.info("getCountrysBySearchText"); List<CountryRepresentation> result = countryFinder.findCountrysBySearchText(searchText); return Response.ok(result).build(); }
2、查询数据
@Override public List<CountryRepresentation> findCountrysBySearchText(String searchText) { String whereSql = ""; String strCondition = ""; if (StringUtils.isNotEmpty(searchText)) { strCondition = "%" + searchText + "%"; whereSql = "where (c.libellePay like :strCondition or c.entityId like :strCondition ) and c.state = 1"; } /* * String sql = "select new " + CountryRepresentation.class.getName() + * "(c.entityId, c.libellePay, c.state, c.payCode2c, c.createDate,c.modifDate) from Country c " + whereSql + " order by c.entityId asc"; * TypedQuery<CountryRepresentation> query = entityManager.createQuery(sql, CountryRepresentation.class); */ String sql = "select c from Country c " + whereSql + " order by c.entityId asc"; TypedQuery<Country> query = entityManager.createQuery(sql, Country.class); if (StringUtils.isNotEmpty(strCondition)) { query.setParameter("strCondition", strCondition); } List<Country> l = query.getResultList(); List<CountryRepresentation> result = new ArrayList<CountryRepresentation>(); for (Country country : l) { result.add(countryAssembler.assembleDtoFromAggregate(country)); } return result; }
0 0
- Angular-UI自动完成输入框AutoComplete[项目中使用]
- 让输入框关闭自动完成(AutoComplete)功能
- YII框架中使用jQuery UI : 自动完成(Autocomplete)--本地数据和使用ajax获取远程数据实例
- jQuery UI 实例 - 自动完成(Autocomplete)
- jQuery UI 实例 - 自动完成(Autocomplete)
- 黑马学习笔记——jQuery UI Autocomplete 输入中文不自动完成问题解决方案
- Jquery UI简单应用——自动完成(Autocomplete)实现类似百度输入提醒效果
- jQuery.Autocomplete输入提示/自动完成插件
- jQuery UI Autocomplete是jQuery UI的自动完成组件
- jQuery UI Autocomplete是jQuery UI的自动完成组件
- JQUERY 的autocomplete UI自动完成控件的运用以及ajax的使用
- 使用AutoComplete Extender实现自动完成功能
- 使用jQuery Autocomplete(自动完成)插件
- 使用jQuery Autocomplete(自动完成)插件
- 使用jQuery Autocomplete(自动完成)插件
- JQuery--使用autocomplete控件进行自动输入完成(相当于模糊查询)
- 自动完成autoComplete,自动补全插件,输入提示
- 调用百度请求 边输入边提示 jQuery UI 自动完成(Autocomplete)支持中文 超简单
- ZOJ 1148 The Game
- 【leetcode每日一题】234.Palindrome Linked List
- Ubuntu 14.04 安装 Vmware Workstation 11
- MFC中消息循环机制
- centos下jdk升级
- Angular-UI自动完成输入框AutoComplete[项目中使用]
- Unreal Engine 4.9 Release Notes
- ubuntu切换成root用户
- 设计模式之facade模式
- 智能手机拍照哪家强?
- [Leetcode]Number of Islands
- mysql出现错误“ Every derived table must have its own alias”
- appDelegate的详解
- Java基础---网络编程