我試圖從AngularJS Bootstrap設置$uibModal
,但是在控制檯中出現錯誤。更多關於下面的內容。AngularJS Bootstrap - 控制檯出錯
app.js:
var app = angular.module('carApp', ['ui-bootstrap']);
ctrl.js
app.controller('carCtrl', function($scope, $http, $uibModal) {
$http.get('jobs.json').success(function(data) {
$scope.data = data;
$scope.open = function() {
var modalContent = $uibModal.open({
templateUrl: 'careersTpl.html',
controller : modalContentCtrl,
resolve: {
items: function() {
return $scope.data;
}
}
})
}
});
});
HTML:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.1/angular-material.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-animate.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-aria.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular-messages.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.2.0/ui-bootstrap-tpls.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="js/app.js"></script>
<script src="js/careersCtrl.js"></script>
</head>
<body data-ng-app="carApp">
<div data-ng-controller="carCtrl" class="car-up">
<script type="text/ng-template" id="careersTpl.html">
<div class="modal-header">
<h3>Lorem Ipsum</h3>
</div>
<div class="modal-body">
<p>{{data}}</p>
</div>
</script>
<button class="btn" ng-click="open()">Open</button>
</div>
</body>
這種類型的錯誤通常顯示,當一些無法正確鏈接。錯誤:
Error: [$injector:modulerr] http://errors.angularjs.org/1.5.7/ $injector/modulerr?p0=carApp&p1=%5B%24injector%3Amodulerr%5D%20http%3A%2F%2Ferrors.angularjs.org%2F1.5.7%2F%24injector%2Fmodulerr%3Fp0%3Dui-bootstrap%26p1%3D%255B%2524injector%253Anomod%255D%2520http%253A%252F%252Ferrors.angularjs.org%252F1.5.7%252F%2524injector%252Fnomod%253Fp0%253Dui-bootstrap%250AO%252F%253C%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js%253A6%253A412%250Ale%252F%253C%252F%253C%252F%253C%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js%253A25%253A72%250Ab%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js%253A24%253A115%250Ale%252F%253C%252F%253C%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js%253A24%253A358%250Ag%252F%253C%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js%253A39%253A374%250Ar%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js%253A7%253A353%250Ag%2540https%253A%252F%252Fajax.googleapis.com%252Fajax%252Flibs%252Fangularjs%252F1.5.7%252Fangular.min.js
請注意jobs.json
是本地服務器上,並沒有出現過Cross-Origin
問題。
爲什麼......確實我把連字符那裏。 ...!?!?!?謝謝隊友......這種愚蠢的問題。 –
哈哈,我每次都做同樣的事情。沒有幫助他們稱之爲* ui-bootstrap *,但是以不同的方式命名模塊。雖然;讚賞upvote;) – Robba
我坐在我的屏幕前,想知道我怎麼錯過了。我真的應該得到我綽號中的「虛擬」部分。 –