2017-03-16 11 views
0

問題があり、理由はわかりません。なぜなら、ローカルサーバーでは動作しますが、プロダクションでは動作しないからです。ディレクティブのモーダルダイアログを閉じる

私はこのようなディレクティブがあります、

だから、
<modal-dialog show='modalShown' types="types"> 

:私は休閑として持っている私のコントローラで

calcP.directive('modalDialog', function() { 
    return { 

     restrict: 'E', 
     scope: { 
      show: '=', 
      types: '=', 
     }, 
     replace: true, 
     transclude: true, 

     link: function(scope, element, attrs) { 
      console.log('scope', scope); 
      scope.dialogStyle = {}; 
      if (attrs.width) 
       scope.dialogStyle.width = attrs.width; 
      if (attrs.height) 
       scope.dialogStyle.height = attrs.height; 
      scope.hideModal = function() { 
       scope.show = false; 
       delete scope.types.individual; 

      }; 

     }, 
     template: "<div class='ng-modal' ng-show='show'><div class='ng-modal-overlay' ng-click='hideModal()'></div><div class='ng-modal-dialog' ng-style='dialogStyle'><div class='ng-modal-close' ng-click='hideModal()'>X</div><div class='ng-modal-dialog-content' ng-transclude></div></div></div>" 
    }; 
}); 

:私は休閑として持っているビューで

$scope.modalShown = false; 
    $scope.toggleModal = function() { 
     $scope.modalShown = !$scope.modalShown; 
     console.log('modalShown', $scope.modalShown); 
    }; 

をconsole.logを使ってみる限り、toggleModal()は機能しません。

答えて

0

機能ホイストを試すことはできますか?代わりに、直接関数の

別途関数を定義し、

$scope.toggleModal = toggleModal; 
function toggleModal() { 
     $scope.modalShown = !$scope.modalShown; 
     console.log('modalShown', $scope.modalShown); 
}; 
+0

のように$スコープに割り当て$スコープ

//what you did $scope.toggleModal = function() { $scope.modalShown = !$scope.modalShown; console.log('modalShown', $scope.modalShown); }; 

試しに割り当てる残念ながら、あなたのソリューションが動作しません。.. –

関連する問題