ngSwitch并未更改为表达式条件

伙计们,我的ngSwitch无法正常工作。看来条件没有完全注册?它始终是默认的div。我正在尝试更新图片,并根据状态显示正确的元素(noPicture [默认],imgLoading,imgReady [显示图片)这是html

            <ng-container [ngSwitch]="'imgStatus'">
              <div *ngSwitchCase="'imgLoading'">LOADING</div>
              <img *ngSwitchCase="'imgReady'" [src]="profileURL" class="ion-align-self-center" />
              <app-default-profile-picture
                *ngSwitchDefault
                [lastNames]="lastNames"
                [contactBox]="true"
              ></app-default-profile-picture>
            </ng-container>

* note **我尝试使用带引号和不带引号,但是基于this article,因为条件是引号,所以我似乎需要引号 这是函数:

  private takePicture(source: number): void {
    const options: CameraOptions = {
      // ...
    };

   this.camera.getPicture(options).then((imageData: string): void => {
        this.imgStatus = 'imgLoading'; // here I set it as loading

        this.api.uploadImage(imagePayload).subscribe((response: ImageResponse): any => {
          if(response.code === 200) {
            this.extPicture = response.data;
            this.imgStatus = 'imgReady';
          } else {
            this.imgStatus = 'imgError';
          }
        })

没有任何变化,任何人都可以看到我在这里想念的东西吗?谢谢

kangjian1207 回答:ngSwitch并未更改为表达式条件

使用这种方式<ng-container [ngSwitch]="imgStatus">

本文链接:https://www.f2er.com/3166761.html

大家都在问