AngularJS Bootstrap - 控制台

时间:2016-11-29 09:48:59

标签: javascript angularjs node.js twitter-bootstrap angular-bootstrap

我正在尝试从AngularJS Bootstrap设置$uibModal,但是我在控制台中收到错误。更多关于以下内容。

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>

当某些内容未正确链接时,通常会显示此类错误。错误:

  

错误:[$ injector:modulerr]   http://errors.angularjs.org/1.5.7/ $注射器/ 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的自举%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%25 3A374%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个问题。

2 个答案:

答案 0 :(得分:1)

UI-bootstrap模块名称有一个点,而不是连字符。

var app = angular.module('carApp', ['ui.bootstrap']);

答案 1 :(得分:1)

据我观察,这是由app.js引起的:

var app = angular.module('carApp', ['ui-bootstrap']);

尝试将ui-bootstrap更改为ui.bootstrap