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