我有一个组件alphabatesComponent
。它具有方法postLetters()
。每当我在wordsComponent
中调用postLetters()
时,我都想调用alphabatesComponent
listOfAlphabates()方法。
//服务
private _listners = new Subject<any>();
constructor(private httpClient: HttpClient) { }
listen(): Observable<any> {
debugger;
return this._listners.asObservable();
}
filter(filterBy: string) {
debugger;
this._listners.next(filterBy);
}
// alphabates组件
export class alphabatesComponent {
postLetters(): void {
this.asynService.filter('Register click');
}
}
//这是我的文字部分
constructor() {
this.asyncService.listen().subscribe((m: any) => {
this.listOfAlphabates();
}
}
listOfAlphabates() {}
}
答案 0 :(得分:0)
对于状态管理,使用rxJs:
在alphabates组件中:
node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod
在asynService中:
filter () {
this.asynService.onFilterChanged.next('Registerclick');
}
在单词部分:
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
public onFilterChanged: BehaviorSubject<any> = new
BehaviorSubject('');