微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在类型 EventEmitter 上观察到的属性不存在

如何解决在类型 EventEmitter 上观察到的属性不存在

我们使用 angular (11.2.14) 并将 rxjs 库更新到 7.1.0。 从那时起,我们在多个地方出现了这个错误属性 'observers' 在类型 'EventEmitter' 上不存在”。 根据我们发现的公关 (https://github.com/ReactiveX/rxjs/pull/6405#issue-645234112) 应该有一个 observed 属性,但它不可用,因为我们使用的是 EventEmitter 而不是 Subject。

构建时出现错误

@Output() readonly onListCreate: EventEmitter<ListDto> = new EventEmitter(); // our emitter

createList() {
        if (!this.newListName) {
            return;
        }

        this.ListService.createList(this.newListName).subscribe((newList) => {
            const newListviewmodel: Listviewmodel = {
                id: newList.id,name: this.newListName,isAdded: false,};
            this.addModuletoList(newList,newListviewmodel);
            this.newListName = "";

            if (this.onListCreate.observers.length === 0) { // error appears here
                this.listsviewmodel.push(newListviewmodel);
                this.ownedAndCoOwnedLists.push(newList);
            }

            this.onListCreate.emit(newList);
        });
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。