3
我正在嘗試使用ng2-auto-complete的列表格式化功能,但無法找到如何實現的一個很好的例子。我有以下代碼至今:如何使用ng2-auto-complete的list-formatter例子?
<input class="form-control input-list" ng2-auto-complete
[(ngModel)]="model4"
placeholder="Search"
[source]="googleGeoCode"
list-formatter="myListFormatter"
path-to-data=""
value-property-name=null
display-property-name=null
min-chars="2"
/>
export class HomeComponent {
templateStr: any = templateStr;
valuePropertyName: string;
displayPropertyName: string;
googleGeoCode: string = "http://localhost:61227/machine/?query=:keyword";
myListFormatter(data: any): string {
let html: string = "";
html += data[this.valuePropertyName] ? `<b>(${data[this.valuePropertyName]})</b>` : "";
html += data[this.displayPropertyName] ? `<span>${data[this.displayPropertyName]}</span>` : data;
return html;
}
}
所以,我怎麼能得到列表格式工作?
我想你忘了問一個問題;) – Alex
什麼是目前的行爲和預期的行爲是什麼? – Alex