在rxjs中使用Subject时遇到问题

时间:2019-04-19 13:01:56

标签: angular rxjs

enter image description here

在rxjs中使用Subject时出现问题。 当我将类型字符串提供给Subject时,它会给出错误

Expected 0 type arguments, but got 1

1 个答案:

答案 0 :(得分:1)

您应该始终在构造函数中初始化主题,

将变量声明为

private _sourceSubject: Subject<string>;

在构造函数中,

this._sourceSubject = new Subject<string>();