我用jHipster 1.4.1创建了一个项目。 jHipster在其angular-bootstrap版本中使用1.3.3来组合bootstrap组件和angular指令。现在,我有兴趣显示具有先前给定值的文本输入的建议,因此我想使用uib-typeahead
指令,但问题是自动完成没有显示。那是我的代码:
bower.json
{
"version": "0.0.0",
"name": "myApp",
"appPath": "src/main/webapp/",
"testPath": "src/test/javascript/spec",
"dependencies": {
"angular": "1.5.8",
"angular-aria": "1.5.8",
"angular-bootstrap": "1.3.3",
"angular-cache-buster": "0.4.3",
"angular-cookies": "1.5.8",
"angular-dynamic-locale": "0.1.32",
"angular-i18n": "1.5.8",
"ngstorage": "0.3.10",
"angular-loading-bar": "0.9.0",
"angular-resource": "1.5.8",
"angular-sanitize": "1.5.8",
"angular-translate": "2.11.1",
"angular-translate-interpolation-messageformat": "2.11.1",
"angular-translate-loader-partial": "2.11.1",
"angular-translate-storage-cookie": "2.11.1",
"angular-ui-router": "0.3.1",
"bootstrap": "3.3.7",
"bootswatch": "3.3.7",
"bootstrap-ui-datetime-picker": "2.4.3",
"jquery": "3.1.0",
"json3": "3.3.2",
"messageformat": "0.3.1",
"modernizr": "3.3.1",
"ng-file-upload": "12.0.4",
"ngInfiniteScroll": "1.3.0",
"swagger-ui": "2.1.5",
"ui-leaflet": "1.0.3",
"angular-nvd3": "1.0.9"
},
"devDependencies": {
"angular-mocks": "1.5.8"
},
"overrides": {
"angular": {
"dependencies": {
"jquery": "3.1.0"
}
},
"angular-cache-buster": {
"dependencies": {
"angular": "1.5.8"
}
},
"angular-dynamic-locale": {
"dependencies": {
"angular": "1.5.8"
}
},
"bootswatch": {
"main": [
"yeti/bootstrap.css"
]
}
},
"resolutions": {
"angular": "1.5.8",
"angular-bootstrap": "1.3.3",
"jquery": "3.1.0"
}
}
app.module.js
(function() {
'use strict';
angular
.module(
'myApp',
[ 'ngStorage', 'tmh.dynamicLocale',
'pascalprecht.translate', 'ngResource',
'ngCookies', 'ngAria', 'ngCacheBuster',
'ngFileUpload', 'ui.bootstrap',
'ui.bootstrap.datetimepicker', 'ui.router',
'infinite-scroll',
// jhipster-needle-angularjs-add-module JHipster
// will add
// new module here
'angular-loading-bar', 'ui-leaflet', 'nvd3',
'ui.bootstrap' ]).run(run);
run.$inject = [ 'stateHandler', 'translationHandler' ];
function run(stateHandler, translationHandler) {
stateHandler.initialize();
translationHandler.initialize();
}
})();
安装-dialog.html
<!-- Not related code -->
<input type="text"
class="form-control" name="business" id="field_business"
ng-model="vm.installation.business"
uib-typeahead="business for business in vm.businesses | filter:$viewValue | limitTo:8"
typeahead-no-results="noResults" />
<!-- Other not related code -->
我检查vm.businesses
是否加载了值,但是当我输入输入时没有显示任何内容。不会抛出任何javascript错误。
知道我能错过什么吗?
修改
安装-dialog.controller.js
InstallationSuggestion.query({
field : 'business'
}, function(result) {
console.log(result);
vm.bussineses = result;
});
加载的商家会显示在控制台中。