我的预先搜索结果显示在实际输入字段上方。公司名称字段是我实际输入的位置,但结果是在其中的北方。
这是我的代码。谁知道我做错了什么?
<span ng-switch-when="typeahead">
<input type="text"
class="form-control"
placeholder="Search..."
typeahead="option.value as option.displayValue for option in formField.options | filter:$viewValue | limitTo:3"
ng-model="formModel[formField.field.columnName]" />
</span>
控制器:
(function(angular){
"use strict";
var module = angular.module('xdock.formField',[]);
module.constant('FORM_FIELD_TYPES', ["text", "number", "date", "lookup", "check", "timepicker", "typeahead"]);
module.directive('formField',[
function formField() {
return {
scope: {
formField: '=',
formLabel: '@',
formModel: '=',
formErrorModel: '='
},
templateUrl: 'common/formField.html',
link: function postLink(scope) {
scope.flags = {datepickerOpen : false};
scope.datepickerOptions = {
showButtonBar: false
};
scope.openDatepicker = function openDatepicker($evt) {
$evt.preventDefault();
$evt.stopPropagation();
scope.flags.datepickerOpen = true;
};
function formatDate() {
if(scope.formField.type === "date" && scope.formModel[scope.formField.field.columnName]) {
scope.formModel[scope.formField.field.columnName] =
new Date(scope.formModel[scope.formField.field.columnName]);
}
}
formatDate();
}
};
}
]);
}(window.angular));