2016-11-28 6 views
0

私は、typescriptとangularを使用して$ uibModalを使用してモーダルを表示しようとしています。は、タイプスクリプトでuibmodalを実行できません

export class PDPController{ 

    static $inject = ['pdpService', '$sce', 'angularLoad', '$uibModalInstance']; 
    constructor(
     pdpService: PDPService, 
     $sce : ng.ISCEService, 
     angularLoad, 
     //initiating in constructor 
     private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance 
    ) { 
     this.pdpService=pdpService; 
     //Need to add promise 
     pdpService.getContentdata(APP_CONSTANT.API_URL_LEARN_MORE) 
      .then((authorContentData) => { 
      this.contentData= authorContentData; 
      pdpService.getPDPdata(APP_CONSTANT.API_URL_LEARN_MORE) 
      .then((pdpData) => { 
      console.log(pdpData); 
      this.setProductDetails(pdpData); 
     }); 
     }); 

    } 
    //method to invoke the modal 
    private showPromo(): void{ 

     console.log("Promo"); 
      var modalInstance = this.$uibModal.open({ 
       animation: "true", 
       templateUrl: 'promoModalContent.html', 
       appendTo: 'body' 
      }); 
    } 
} 

//module: 
let module: ng.IModule = angular.module(pdpModule, ['ui.bootstrap']); 

私はがぶ飲みビルドを実行したときに、私は、このエラーに直面しています:

Unknown provider: $uibModalInstanceProvider <- $uibModalInstance 
Module 'angular.ui' has no exported member 'bootstrap'. 
私は、コードを実行したときに

$ uibModalが認識されない: エラー:プロパティ「$ uibModalは」タイプに存在しません。 'PDPController'。

私はTypescriptを完全に使いこなしており、ここでの解決方法を理解することはできません。 ご案内ください。

答えて

0

$uibModalを注射しませんでした。 ...

static $inject = ['pdpService', '$sce', 'angularLoad', '$uibModalInstance', '$uibModal']; 
+0

試してみてください...うまくいきません! この特定のエラーを解決する方法を教えてください - > モジュール 'angular.ui'にはエクスポートされたメンバー 'bootstrap'がありません。 – Aashish

0

私はこの問題を解決することができますが、本当にこれが働いていた方法を知っていけない:あなたの$injectにそれを追加してみてください! 編集私が作っ:

export class PDPController { 
    public $uibModal: ng.ui.bootstrap.IModalService; 
    public modal: any; 

    //injected $uibModal 
    static $inject = ['pdpService', '$sce', 'angularLoad', '$uibModal']; 
    //initiated $uibModal 
    constructor(
     pdpService: PDPService, 
     $sce: ng.ISCEService, 
     angularLoad, 
     $uibModal: ng.ui.bootstrap.IModalService 
    ) { 
     // i had to assign the value of $uibModal to a new variable, otherwise 
     //$uibModal is undefined when accessed in the function showPromo(). 
     this.modal = $uibModal; 
    } 

    private showPromo(): void { 

     let modalInstance = this.modal.open({ 
      animation: "true", 
      templateUrl: 'promoModalContent.html' 
     }); 
    } 
} 

我々は新しい変数を必要とする理由誰かが説明できる場合、それは素晴らしいことでしょう!

関連する問題