如何使用 ngIf 使用异步管道检查字符串数组中的值?

How to check for a value in array of strings with ngIf using async pipe?

我使用 NgRx-store 管理我的应用程序状态。我正在检查的商店数据片段可以是一个字符串或一个字符串数组。我想使用 *ngIf 检查该字符串或数组是否具有特定值?

我现在正在做的是订阅存储值的切片并将布尔常量返回给 *ngIf

在我的组件中,

isRegistry: boolean;
isEmbryology: boolean;
authStoreData: Subscription;
 ngOnInit() {
    this.authStoreData = this.store.select(c => c.auth).subscribe(
      (data: fromAuth.State) => {
        const userDatabases = data.entities[fromAuth.authId].userData.userDatabases;
        let userDatabaseCollection: Array<string> = [];
        isArray(userDatabases) ? userDatabaseCollection = userDatabases :
        userDatabaseCollection.push(userDatabases);
        for (const databaseKey in userDatabaseCollection) {
          if (userDatabaseCollection[databaseKey]) {
            if (userDatabaseCollection[databaseKey] === 'Clinic Database') { this.isRegistry = true; };
            if (userDatabaseCollection[databaseKey] === 'Embryology Database') { this.isEmbryology = true; };
          }
        };
      }
    );


   }
  ngOnDestroy() {
    this.authStoreData.unsubscribe();
  };

在我的模板中,我检查了 isRegistryisEmbryology 等 ..

我现在的方法是 select 使用 async pipe 的商店切片来获取数据,但是如果我正在处理一个在这里排列;像这样

authData: Observable<any>;
this.authData = this.store.select(c => c.auth.entities[fromAuth.authId]);

在我的模板中

 <li *ngIf="(authData | async ).userData.userDatabases == 'Clinic Database'">

答案就在我面前,.includes()

<li *ngIf="(authData | async).userData.userDatabases.includes('Clinic Database')" >