1

I'm trying to set up $uibModal from AngularJS Bootstrap, however I get an error in console. More on that below.

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>

This type of errors is usually displayed, when something is not linked correctly. Error:

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

Please note that jobs.json is on local server and there have been no Cross-Origin issues.

0

2 Answers 2

1

The UI-bootstrap module name has a dot, not a hyphen.

var app = angular.module('carApp', ['ui.bootstrap']);
Sign up to request clarification or add additional context in comments.

2 Comments

Haha, I do the same thing every time. Doesn't help that they call it ui-bootstrap but then name the module differently. An upvote would be appreciated though ;)
I'm sitting in front of my screen and wondering how did I miss that. I really deserve the "dummy" part in my nickname.
1

From what I've observed, this is caused by app.js:

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

Try changing ui-bootstrap into ui.bootstrap

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.