Angular 16 takeUntilDestroyed 运算符具有两种订阅方法

标签 angular angular16

示例来自 ( https://indepth.dev/posts/1518/takeuntildestroy-in-angular-v16 ) 这适用于一种订阅方法,但不适用于两种方法

如果你看下面的代码,那么当组件被销毁时,第二个订阅就会存在。我只是不明白为什么以及如何使代码适用于组件中任意数量的订阅?也许我误解了什么?

import { takeUntilDestroyed } from '@angular/core/rxjs-interop'

  constructor(
  ) {
    interval(1000).pipe(
      takeUntilDestroyed(),
    ).subscribe(console.log)

    interval(1000).pipe(
      takeUntilDestroyed(),
    ).subscribe(console.log)
  }

最佳答案

This issuefixed随着 16.0.2 的发布!

关于Angular 16 takeUntilDestroyed 运算符具有两种订阅方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76279303/

相关文章:

angular - Visual Studio Code Typescript 避免在新行上使用参数

angular - Observable .catch 不是一个函数

javascript - Angular 2 : read object with unknown key

javascript - Angular 5 : Access element inner html from the component for dynamically generated elements

javascript - Angular 2 :how to use the observable to broadcast event within forEach?

从共享模块导出 Angular 16 组件不起作用