2016-03-04 44 views
0

下面的代碼不能處理縮小,這看起來很明顯(控制器依賴性在縮小後不會工作)。有人可以提出一個理想的方法來寫下面的代碼,這個代碼也適用於縮小。只是爲了您的信息,我正在使用打字稿,而我並不打算爲控制器創建新的類或功能,因爲它非常小,所以我更願意編寫內聯塊。在此先感謝..縮小後的角碼不工作

public openSpinModal(): void { 
      if (!this.spinModalInstance) { 
       this.marsAction.closeModal(); 
       this.isNeedToClsoe = false; 
       this.spinModalInstance = this.$modal.open({ 
        animation: true, 
        templateUrl: 'module/common/components/mars-modal/spinModalContent.html', 
        size: 'sm', 
        windowClass: "modal-vertical-centered", 
        controller: ($scope, $modalInstance) => { 
         this.marsAction.closeModal =() => { 
          $modalInstance.close(); 
          this.isNeedToClsoe = true; 
         }; 
        } 
       }); 

       //removed code to keep question cleraner 
      } 
     } 

回答

0

下面的代碼爲我工作 -

public openSpinModal(): void { 
       if (!this.spinModalInstance) { 
        this.marsAction.closeModal(); 
        this.isNeedToClsoe = false; 
        this.spinModalInstance = this.$modal.open({ 
         animation: true, 
         templateUrl: 'module/common/components/mars-modal/spinModalContent.html', 
         size: 'sm', 
         windowClass: "modal-vertical-centered", 
         controller: ["$scope", "$modalInstance" , ($scope, $modalInstance) => { 
          this.marsAction.closeModal =() => { 
           $modalInstance.close(); 
           this.isNeedToClsoe = true; 
          }; 
         } 
        }]); 

        //removed code to keep question cleraner 
       } 
      }