首页 > 解决方案 > Angular 中的更改检测冻结浏览器

问题描述

我的函数 permission() 可以完美运行,但是当我调用函数 deleteChannel() 时,它会冻结我的浏览器。

async havePermission(channelId) {
        if (await this.isPrivateChannel2(channelId) && !(await this.inChannel(channelId))) {
            return false;
        } else {
            return true;
        }
    }

async permission(channelId) {
        console.log(await this.havePermission(channelId));
        return await this.havePermission(channelId);
    }
}

在模板中使用它:

<app-chat *ngIf="permission(channelId) | async" [channelId]="channelId"></app-chat>

删除频道功能:

 deleteChannel(channel) {
            this.channelId = channel.$key;
            this.channels.remove(this.channelId);
            this.channelMessages.remove(this.channelId);
            this.chUsers.remove(this.channelId);
        }

当我调用 deleteChannel() 时,我有数千个来自 permission() 函数的 console.log() 。我认为问题在于 Angular 中的更改检测,但我不知道我应该怎么做才能让它工作。有什么建议么?

标签: javascriptangular

解决方案


推荐阅读