コードサンプルは表示されません。私はあなたが既にフェッチデータをフィルタリングしていることを願っています。別のデータセットを取得する必要がある場合は、そのデータを親コンポーネントに送り返す必要があります。
これを実行する方法はたくさんあります。 @Outputを使用して、親コンポーネントに関数を送出します。または、サービスとObservableを使用します。
ここでは、サービスの使用時に尋ねたサンプルを示します。 https://angular.io/guide/component-interaction#parent-and-children-communicate-via-a-service
// test.service.ts
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/subject';
@Injectable()
export class TestService {
// Source
private list = new Subject<Object[]>();
// Observable Stream
public list$ = this.list.asObservable();
constructor() {}
updateList(data) {
this.list.next(data);
}
}
// parent.component.ts
import { Component, OnInit } from '@angular/core';
import { TestService } from 'services/test.service.ts';
@Component({
selector: 'parent-name',
templateUrl: 'parent.component.html',
providers: []
})
export class ParentComponent implements OnInit {
list;
constructor(
private testService: TestService
) {
testService.list$.subscribe(data => {
this.list = data;
});
}
ngOnInit() { }
}
// child.component.ts
import { Component, OnInit } from '@angular/core';
import { TestService } from 'services/test.service.ts';
@Component({
selector: 'child-name',
templateUrl: 'child.component.html'
})
export class ChilComponent implements OnInit {
list;
constructor(
private testService: TestService
) { }
ngOnInit() { }
update(){
this.testService.updateList(list);
}
}
https://angular.io/guide/component-interaction –