如何从y分量中提取x分量中的函数?

时间:2019-04-18 19:45:31

标签: angular6

我有一个组件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() {}

}

1 个答案:

答案 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('');