2015-10-13 24 views
0

我希望模態窗體彈出窗口,但不會出現。當我正在檢查元素 它說$(...)模態不是一個函數。 控制器:在角度js中彈出的模態窗體

AuthService.createAdmin(data, function (response) { 
    if (response.data.success == true) { 
     $location.path('/superAdmin'); 
    } else if (response.data.success == false && response.data.errorCode == 100) { 
     $('#myModal').modal('show'); 
    } else { 
     $location.path('/superAdmin'); 
    } 
}); 

HTML:

<div class="modal-dialog"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
      <h4 class="modal-title">Info</h4> 
     </div> 

     <div class="modal-body"> 

      <p>The email address {{email}} already exists</p> 
     </div> 

     <div class="modal-footer"> 
      <button data-dismiss="modal" ng-click="handleBack()" class="btn btn-default" id="cancel" type="button">OK</button> 
     </div> 

    </div> 
</div> 
</div> 
+0

$( '#myModal')顯示()? –

+0

不工作#Simon Pertersen –

+0

檢查你的引導CSS類。這是淡入淡出的問題。這是開放的,但我認爲不顯示。 –

回答

0
要使用angularjs.You必須更改HTML體,並添加controller.Following代碼

處於angularjs模式窗體彈出樣品。

HTML正文部分:

<div ng-controller="ModalDemoCtrl"> 
    <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 href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a> 
       </li> 
      </ul> 
      Selected: <b>{{ selected.item }}</b> 
     </div> 
     <div class="modal-footer"> 
      <button class="btn btn-primary" type="button" ng-click="ok()">OK</button> 
      <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button> 
     </div> 
    </script> 

    <button type="button" class="btn btn-default" ng-click="open()">Open me!</button> 
</div> 

控制器部分:

angular.module('modalSample').controller('ModalDemoCtrl', function ($scope, $uibModal, $log) { 

    $scope.items = ['item1', 'item2', 'item3']; 

    $scope.animationsEnabled = true; 

    $scope.open = function (size) { 

    var modalInstance = $uibModal.open({ 
     animation: $scope.animationsEnabled, 
     templateUrl: 'myModalContent.html', 
     controller: 'ModalInstanceCtrl', 
     size: size, 
     resolve: { 
     items: function() { 
      return $scope.items; 
     } 
     } 
    }); 

    modalInstance.result.then(function (selectedItem) { 
     $scope.selected = selectedItem; 
    }, function() { 
     $log.info('Modal dismissed at: ' + new Date()); 
    }); 
    }; 


}); 


angular.module('modalSample').controller('ModalInstanceCtrl', function ($scope, $modalInstance, items) { 

    $scope.items = items; 
    $scope.selected = { 
    item: $scope.items[0] 
    }; 

    $scope.ok = function() { 
    $modalInstance.close($scope.selected.item); 
    }; 

    $scope.cancel = function() { 
    $modalInstance.dismiss('cancel'); 
    }; 
});