2017-04-09 8 views
0

私は、同じFirefoxで自分のアプリケーションを実行しているないはエッジで発生しない場合、次のエラーを取得、またはクローム:角度のFirefox(|新しい|クラスのコンストラクタはで呼び出さなければなりません)

TypeError: class constructors must be invoked with |new| Stack-Trace:

h/<[email protected]://localhost:8080/js/angular.min.js:44:169 
wf/this.$get</</<@http://localhost:8080/js/angular.min.js:94:33 
[email protected]://localhost:8080/js/angular.min.js:69:42 
ga/<@http://localhost:8080/js/angular.min.js:80:323 
h/<@http://localhost:8080/js/angular.min.js:134:467 
Mf/this.$get</[email protected]://localhost:8080/js/angular.min.js:145:417 
Mf/this.$get</[email protected]://localhost:8080/js/angular.min.js:149:111 
[email protected]://localhost:8080/js/angular.min.js:102:87 
wg/</[email protected]://localhost:8080/js/angular.min.js:107:489 

追加コンテキスト:私はAngularを初めて利用しています。これを修正またはデバッグする場所はどこにもありません。

マイmain.jsは次のようになります。

angular.module('appointmentApp') 
    .component('main', { 
    templateUrl: 'app/main.html', 
    controller: MainController 
    }); 

質問: 誰かがデバッグについて移動する方法で私に助言し、このブラウザ固有の問題を解決することはできますか?

編集:いくつかのより多くのコード

'use strict'; 
 

 
(function() { 
 

 
class MainController { 
 

 
constructor($http,$mdMedia,$mdDialog) { 
 
    this.message = 'Hello'; 
 
    this.$http=$http; 
 
    this.appointment = []; 
 
    this.slots = []; 
 
    this.$mdMedia = $mdMedia; 
 
    this.$mdDialog = $mdDialog; 
 
    //... 
 
    } 
 

 
    
 
    save(appointment){ 
 
    //... 
 
    }); 
 
     
 
    } 
 
    
 
    $onInit(){ 
 
    var vm = this; 
 
    this.$http.get('/api/data').then(response=>{ 
 
     this.data=response.data; 
 
     this.dates = this.allot(this.slots,this.days,this.appointments); 
 
    }); 
 
    } 
 

 
    
 

 
allot(slots, days, appointments){ 
 
//... 
 
} 
 

 

 
    showAdvanced(slot) { 
 
     var vm = this; 
 
    var useFullScreen = (this.$mdMedia('sm') || this.$mdMedia('xs')) && this.customFullscreen; 
 
    this.$mdDialog.show({ 
 
     controller: function($scope,$mdDialog,slot){ 
 
      $scope.customer = {}; 
 
      $scope.customer.slot = slot; 
 
     $scope.answer = function(answer){ 
 
      $mdDialog.hide(answer); 
 
     }; 
 
     }, 
 
     templateUrl: 'app/customer.html', 
 
     locals : { 
 
      slot : slot 
 
     }, 
 
     clickOutsideToClose:true, 
 
     fullscreen: useFullScreen 
 
    }) 
 
    .then(function(answer) { 
 
     answer.date = answer.slot.date; 
 
     vm.save(answer); 
 
    }); 
 
    
 
    } 
 
    
 
    getColor($index) { 
 
    var _d = ($index + 1) % 11; 
 
    var bg = ''; 
 

 
    switch(_d) { 
 
     case 1:  bg = 'green';  break; 
 
     case 2:  bg = 'darkBlue'; break; 
 
     default:  bg = 'yellow';  break; 
 
    } 
 

 
    return bg; 
 
    } 
 
    
 

 
} 
 

 
angular.module('appointmentApp') 
 
    .component('main', { 
 
    templateUrl: 'app/main.html', 
 
    controller: MainController 
 
    }); 
 

 
})();

+0

MainControllerのコードを共有してもらえますか? –

答えて

0

角度との組み合わせでネイティブES6クラスのサポートに関するFirefoxのバグがありました。 https://bugzilla.mozilla.org/show_bug.cgi?id=1216630

そして、ここで対応するAngularJS問題のブログ::https://github.com/angular/angular.js/issues/14240#issuecomment-197418167

を別の方法として、あなたの中にES6-> ES5のtranspilationステップを含むことができ、これは、ここでは、バグレポートを参照してくださいFFバージョンで55

を修正しましたネイティブのES6サポートが古いブラウザのバージョンでは危険になる可能性があるため、ビルド(例:Babel)

関連する問題