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