将组件作为参数传递

时间:2019-07-17 19:22:59

标签: angular

我有多个对话框组件,需要根据documentType打开。有没有一种方法可以将组件暂停到以下方法。这样做的最好方法是什么。我可以使用数十条if..else语句来做到这一点,但这似乎不是正确的方法。

 previewDialog(pdfCase, party, documentType) {
        this.dialogRef = this.dialog.open(DOCT030DialogComponent, { 
//on the basis of documentType I need to open different components
          panelClass: 'mail-compose-dialog',
          data: {
            case: pdfCase,
            party: party,
            documentType: documentType
          }
        });
        this.dialogRef.afterClosed()
          .subscribe(response => {

            if (!response) {
              return;
            }
            const actionType: string = response[0];

            switch (actionType) {
              /**
               * Send
               */
              case 'send':

                break;
              /**
               * Delete
               */
              case 'delete':
                //this.caseService.getVisits(this.caseId);
                break;
            }
          });
      }

0 个答案:

没有答案