我正在尝试使用list-formatter功能进行ng2-auto-complete,但无法找到如何实现它的一个很好的例子.到目前为止,我有以下代码:
@H_403_11@<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;
}
}
那么,我怎样才能使list-formatter工作?