如何寫一些@Pipe
用於過濾(在<input>
標籤)在表中的數據?濾波器輸入在角2
<tr *ngFor='let list of lists'>
<td><input type="" name="" value=""></td>
<td>{{ list.name }}</td>
<td>{{ list.location }}</td>
<td>{{ list.type_id }}</td>
<tr>
的數據,我從API獲得與HTTP服務:
getServices(): Observable<any> {
return this._http.get(this._url)
.map(res => res.json());
}
UPD:
這是我的服務組件:
import {Injectable} from '@angular/core';
import {Http, Headers, RequestOptions} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/operator/map'
@Injectable()
export class TableComponentService{
private _url = 'http://101.496.222.511:8080/api/v1/10';
constructor(private _http: Http) {
}
names:string[];
getServices(): Observable<any> {
return this._http.get(this._url)
.map(res => res.json());
}
}
,這是一個表組件
import { Component, OnInit } from '@angular/core';
import { TableComponentService } from './table.service';
@Component({
selector: 'tablecomponent',
templateUrl: 'app/table.template.html',
providers: [TableComponentService]
})
export class TableComponent implements OnInit {
lists: any[];
constructor(private _service: TableComponentService) {
}
ngOnInit() {
this._service.getServices()
.subscribe(lists => this.lists = lists)
}
}
u能解釋一下你在''標籤我寫的一些符號filering正是 –
@Atal紀的意思,然後找到完整的單詞。例如,寫一個 - 然後找到阿爾法 –
爲什麼ü想使用管道而不是在改變事件只是調用getservices(),並存儲在一個變量接收到的值,並利用可變 –