1
我想在使用typeahead.js的Angular2應用程序中實現typeahead。在打字稿文件中,我添加了以下導入段。javascript:提供的參數不匹配呼叫目標的任何簽名
import initTypeahead = require("../../../assets/js/init/dashboard.js");
dashboard.d.ts
declare function initTypeahead(data:any,id:any): void;
export = initTypeahead(data,id);
dashboard.js
if ('undefined' !== typeof module) {
module.exports = function initTypeahead(data, element) {
console.log(data);
console.log(element);
var _values = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: data
});
_values.initialize();
var elt = $(element);
elt.tagsinput({
itemValue: 'code',
itemText: 'value',
typeaheadjs: {
name: '_values',
displayKey: 'value',
source: _values.ttAdapter()
}
});
}
}
然後在打字稿添加下列行。
private getCities(): void {
this.componentsService.getCriteriaValues(this.product, "city").subscribe(res => {
initTypeahead(res.returnData, '#city'); // error at this line
});
}
以下錯誤顯示出來的納克服務
Supplied parameters do not match any signature of call target.
任何建議高度讚賞。
謝謝
你使用的是Angular-cli嗎? – SrAxi
@SrAxi,是的,我正在使用angular-cli – Rose18