Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
91
rated 0 times [  95] [ 4]  / answers: 1 / hits: 28332  / 9 Years ago, thu, december 24, 2015, 12:00:00

I'm trying to inject $uibModal into my project, however when the controller loads, I get the following error:



Error: [$injector:unpr] Unknown provider: $uibModalProvider <- $uibModal <- abilityListController


I'm using NuGet for my package management.



Angularjs: 1.4.8



Bootstrap: 3.3.6



Angular-Ui-Bootstrap: 0.14.3



Here's the relevant code:



Index.html



<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset=utf-8 />
<link href=Content/bootstrap.css rel=stylesheet />
<script src=scripts/angular.js></script>
<script src=scripts/angular-ui/ui-bootstrap.js></script>
<script src=app/app.js></script>
<script src=app/homeController.js></script>
<script src=app/abilityList/abilityListController.js></script>
</head>
<body>
<div ng-app=tecApp>
<div ng-controller=homeController as vm>
</div>
<div ng-controller=abilityListController as vm ng-if=true>
<div ng-include='app/abilityList/abilityList.html'></div>
</div>
</div>
</div>
</body>
</html>


app.js:



angular.module(tecApp, []);


AbilityListController.js:



angular
.module('tecApp')
.controller('abilityListController', AbilityListController);

AbilityListController.$inject = ['$uibModal'];

function AbilityListController($uibModal) {
var vm = {};
return vm;
}


I think I'm injecting incorrectly, but it might have to do with how i've included my source files.



I get no console errors aside from the one mentioned above.



I prefer this syntax for my angular code, so I'm hoping for a fix to my code rather than using ('controllername', ['$stuff', 'moreStuff']).



Thanks in advance for any help.


More From » angularjs

 Answers
128

You should inject dependent module before you use it. Your code should be like this:



angular
.module('tecApp',['ui.bootstrap'])

[#63957] Monday, December 21, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
austonjuancarlosb

Total Points: 238
Total Questions: 89
Total Answers: 99

Location: Chad
Member since Mon, Dec 5, 2022
1 Year ago
;