2014-11-14 6 views
1

내 코드는이각도 부트 스트랩 - UI 모달 던져 오류

<div id="palletapp" class="content" ng-app='myApp' ng-controller="MainCtrl" style="display: none"> 


     <script type="text/ng-template" id="myModalContent.html"> 
       <div class="modal-header"> 
        <h3 class="modal-title">I'm a modal!</h3> 
       </div> 
       <div class="modal-body"> 
        <ul> 
         <li ng-repeat="item in items"> 
          <a ng-click="selected.item = item">{{ item }}</a> 
         </li> 
        </ul> 
        Selected: <b>{{ selected.item }}</b> 
       </div> 
       <div class="modal-footer"> 
        <button class="btn btn-primary" ng-click="ok()">OK</button> 
        <button class="btn btn-warning" ng-click="cancel()">Cancel</button> 
       </div> 
      </script> 
     <button class="btn btn-default" ng-click="open()">Open me!</button> 

    </div> 



angular.module('myApp', ['angular-loading-bar', 'ui.bootstrap']).controller('MainCtrl', [ 
    '$http', '$scope', '$modal', '$filter', function ($http, $scope, $filter, $modal) { 
     $scope.open = function(size) { 
      var modalInstance = $modal.open({ 
       templateUrl: 'myModalContent.html', 
       controller: 'ModalInstanceCtrl', 
       size: size, 
       resolve: { 
        items: function() { 
         return $scope.items; 
        } 
       } 
      }); 
     } 
    } 
]); 

모든 것이 나에게 괜찮아 보이는 것과 같습니다. 그러나 버튼을 클릭하면 오류가 발생합니다.

TypeError: undefined is not a function. at line 
    var modalInstance = $modal.open({ 

부트 스트랩 UI 참조를 모두 올바르게 추가했습니다. 내가 잘못하고있는 것을 지적 할 수 있습니까?

답변

3

당신은 잘못된 순서 종속성을 주입됩니다 $modal 서비스 목록에서 세 번째 하나입니다

'$http', '$scope', '$modal', '$filter', function ($http, $scope, $filter, $modal) { 

하는 것으로.

관련 문제