我無法使plugin與角度項目模板一起工作.GitHub僅顯示native和XML中的代碼.Sample插件代碼有效,但不幸的是沒有角度支持或幫助。我無法在角模板上顯示。 相關的代碼,我使用如何使用nativescript-autocomplete插件與nativescript角?
detail.component.ts
registerElement("AutoComplete",() => require("nativescript-autocomplete").AutoComplete);
public list :Array = ['1','2','3','4','567'] ;
public itemTapped(args){
console.log("tapped");
}
detail.component.html
<AutoComplete items=""{{list}}"" itemTap="itemTapped($event)"> </AutoComplete>
我在控制檯收到異常,而頁面加載和自動完成不工作
this.items.forEach is not a function inside plugin code .that line is with definition of AutoComplete.prototype.itemsUpdate inside autocomplete.android.js plugin source
調試到插件的源它打破了在初始化時:
'AutoComplete.prototype.itemsUpdate = function (items) {
var arr = Array.create(java.lang.String, this.items.length);
this.items.forEach(function (item, index) {
arr[index] = item;
});
var ad = new android.widget.ArrayAdapter(app.android.context, android.R.layout.simple_list_item_1, arr);
this._android.setAdapter(ad);
};'
你可能想看看nativescript-telerik-ui插件(https://www.nativescript.org/ui-for-nativescript)。它有一個免費版本和專業版本,其中包括一個AutoCompleteTextView組件。不幸的是,它不支持Angular,但它會在插件的下一個版本中。 –