我正在尝试http://angular-ui.github.io/bootstrap中给出的模态示例。当我单击某个操作的按钮时,我的屏幕变得模糊,好像弹出了一些窗口,但我没有看到任何东西,当我打开模式时控制台会说这个
加载资源失败:服务器响应状态为 404 (Not Found) --- Cannot GET /function%20(a,b)%7Breturn%20b.templateUrl%7C%7C%22template/modal/window.html%22 %7D Uncaught TypeError: undefined is not a function --- angular.min.js
我的控制器
'use strict'
var LoginCtrl = ['$scope', '$modal', '$log', function($scope, $modal, $log) {
$scope.items = ['item1', 'item2', 'item3'];
$scope.open = function (size) {
var modalInstance = $modal.open({
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());
});
};
}];
var ModalInstanceCtrl = ['$scope', '$modalInstance', 'items', 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');
};
}];
我的模板
<div>
<script type="text/ng-template" id="myModalContent.html">
<div>
<h3 class="modal-title">I m a modal</h3>
</div>
<div>
<ul>
<li ng-repeat="item in items">
<a ng-click="selected.item = item">{{ item }}</a>
</li>
</ul>
Selected: <b>{{ selected.item }}</b>
</div>
<div>
<button ng-click="ok()">OK</button>
<button ng-click="cancel()">Cancel</button>
</div>
</script>
<button ng-click="open()">Open me!</button>
<button ng-click="open('lg')">Large modal</button>
<button ng-click="open('sm')">Small modal</button>
<div ng-show="selected">Selection from a modal: {{ selected }}</div>
</div>
为什么我看到这个奇怪的错误。我正在加载 0.11.2 版的 ui-bootstrap-tpls.min.js 和 1.3.1 版的 angular.min.js。我在这里提到了同样的问题,正如其中一位所说,我也有更新的版本。任何建议都会有很大帮助谢谢。