I`ve在角2過濾
創建了一個簡單的表格應用而現在,我的任務就是在<input>
標籤創建數據的過濾器。
<tr>
<td><input type="" name="" value=""></td>
<td><input type="" name="" value=""></td>
<td></td>
<td></td>
<td><input type="" name="" value="" size="7" (keyup)="_service.getServices()"></td>
</tr>
我得到的數據與此:
private _url = 'http://150.746.21.851/api/v1/';
constructor(private _http: Http) {
}
getServices(): Observable<any> {
return this._http.get(this._url)
.map(res => res.json())
}
這是_service
constructor(public _service: TableComponentService) {
}
ngOnInit() {
this._service.getServices()
.subscribe(lists => this.lists = lists)
}
我沒有錯誤的任何記錄。當我在<input>
輸入一些單詞時,沒有任何反應。也許在語法上的錯誤?
UPD:
@Component({
selector: 'tablecomponent',
templateUrl: 'app/table.template.html',
providers: [TableComponentService]
})
export class TableComponent implements OnInit {
lists: any[];
constructor(public _service: TableComponentService) {
}
ngOnInit() {
this._service.getServices()
.subscribe(lists => this.lists = lists)
}
}
,這是模板的一部分:
<table class="table table-bordered table, table table-hover">
<thead>
<tr>
<td colspan="10" align="center">Перечень объектов по теме</td>
</tr>
<tr>
<th>vol 1</th>
<th>vol 2</th>
<th>vol 3</th>
</tr>
<tr style="background: #F5F5F5">
<td><input type="" name="" value=""></td>
<td><input type="" name="" value=""></td>
<td></td>
<td></td>
<td><input type="" name="" value="" size="7" (keyup)="_service.getServices()"></td>
</tr>
</thead>
<tbody>
<tr *ngFor='let list of lists'>
<td contenteditable="true">{{ list.name }}</td>
<td contenteditable="true">{{ list.location }}</td>
</tr>
<tbody>
你想做什麼?你會如何過濾數據? – micronyks
@micronyks 標籤我寫了一些符號,然後找到完整的單詞。例如,寫A - 然後找到Alpha –
那麼webapi返回正確的結果(json對象)? – micronyks