我创建了Subject
来填充一些事件点击:
<button type="search" class="btn btn-primary" (click)="search()">
<i class="fa fa-search" aria-hidden="true"></i> Cercar
</button>
我的组件是:
private searchClickSubject:Subject<void>;
private searchClick$:Observable<void>;
constructor() {
this.searchClickSubject = new Subject<void>();
this.searchClick$ = this.searchClickSubject.asObservable(); <<<1>>>
}
private search(): void {
this.searchClickSubject.next();
}
尽管如此,在<<<1>>>
,this.searchClick$ = this.searchClickSubject.asObservable();
之后,它会返回undefined
。
有什么想法吗?