离子viewchild变量在ng-switch中不可用

时间:2018-05-29 10:37:42

标签: javascript angular ionic-framework

使用以下代码学习离子

@ViewChild(MultiImageUploadComponent) multiImageUpload: MultiImageUploadComponent;

然而,当我尝试使用离子段和ng-switch实现制表符时,我看不到从第二个制表符访问multiImageUpload。像这样。我不断收到错误co.multiImageUpload每次切换到第二个标签时都是未定义的

<ion-segment [(ngModel)]="defaultTab">
    <ion-segment-button value="managePhotos">
        Manage Photos
    </ion-segment-button>
    <ion-segment-button value="addPhotos">
        Add Photos
    </ion-segment-button>

  </ion-segment>
  <div [(ngSwitch)]="defaultTab">
        <ion-grid *ngSwitchCase="'managePhotos'">
          <ion-row>
            <ion-col col-6 col-md-4 col-xl-3 *ngFor="let photo of storyData.photos">
              <div class="image-container" [style.background-image]="'url('')'" (click)='photo()'></div>
            </ion-col>
          </ion-row>
        </ion-grid>
        <ion-grid *ngSwitchCase="'addPhotos'">
            <ion-row>
                <multi-image-upload></multi-image-upload>
                <button ion-button block (click)="newStory()" *ngIf="!multiImageUpload.isUploading && !uploadFinished">
                    <ion-icon name="checkmark"></ion-icon>
                    Upload
                </button>
                <button ion-button block (click)="cancel()" color="danger" *ngIf="multiImageUpload.isUploading && !uploadFinished">
                    <ion-icon name="close"></ion-icon>
                    Cancel
                </button>
            </ion-row>
        </ion-grid>
  </div>

0 个答案:

没有答案