javascript - 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 中的更改检测,但我不知道我应该怎么做才能让它工作。有什么建议么?
解决方案
推荐阅读
- java - 只有当某个方法内的所有线程都完成时,才应该开始某个代码行
- python - Keras 功能 API:用于多输入模型的 train_on_batch 和张量第二维的可变大小
- apache-spark - 在 Jupyter 中显示完整的 Scala Spark 数据框
- javascript - 尝试过滤提取的数据库信息时出现卸载组件警告
- cisco - 如何在 cisco nso_cli 中删除用户默认密码?
- c++ - 如何在 Visual Studio 中抑制命令行警告?
- c++ - Mac OS BigSur 中的 SMFL 库未加载错误
- spring - 将 BIRT 查看器添加到 Spring 项目
- java - 如何做一个简单的rest api控制器测试?
- javascript - 有没有办法在 web pack 中使用 Dart Sass 命令行版本?