Reputation: 3560
I am getting this below error while click on link using Angular.js.
Error:
VM1186 angularjs.js:107 Error: [$injector:unpr] http://errors.angularjs.org/1.4.6/$injector/unpr?p0=UploadProvider%20%3C-%20Upload%20%3C-%20adminCatCategoryController
at Error (native)
at https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:6:416
at https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:40:409
at Object.d [as get] (https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:38:394)
at https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:40:483
at d (https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:38:394)
at e (https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:39:161)
at Object.instantiate (https://run.plnkr.co/8hsX4IhGSoTXwnkj/angularjs.js:39:310)
My code is below.
index.html:
<html ng-app="Spesh">
<head>
<link data-require="bootstrap@*" data-semver="4.0.0-alpha.2" rel="stylesheet" href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" />
<script data-require="bootstrap@*" data-semver="4.0.0-alpha.2" src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js"></script>
<script data-require="jquery@*" data-semver="3.0.0" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
<script src="angularjs.js" type="text/javascript"></script>
<script src="angularuirouter.js" type="text/javascript"></script>
<script src="angularuibootstrap.js" type="text/javascript"></script>
<script src="loginRoute.js" type="text/javascript"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>Test tab</h1>
<div ui-view></div>
<script src="adminController.js" type="text/javascript"></script>
<script src="adminCategoryController.js" type="text/javascript"></script>
<script src="adminCatCategoryController.js" type="text/javascript"></script>
<script src="adminSubcatCategoryController.js" type="text/javascript"></script>
</body>
</html>
loginRoute.js:
var Admin = angular.module('Spesh', ['ui.router','ui.bootstrap']);
Admin.run(function($rootScope, $state) {
$rootScope.$state = $state;
});
Admin.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/');
$stateProvider
.state('/', {
url: '/',
templateUrl: 'dashboard.html',
controller: 'adminController'
})
.state('category', { /* This state defines the department management page */
url: '/category',
templateUrl: 'category.html',
controller: 'adminCategoryController'
})
.state('category.cat', { /* This state defines the department management page */
url: '/manage_category',
templateUrl: 'manage_category.html',
controller: 'adminCatCategoryController'
})
.state('category.subcat', { /* This state defines the department management page */
url: '/manage_subcategory',
templateUrl: 'manage_subcategory.html',
controller: 'adminSubcatCategoryController'
})
})
dashboard.html:
<nav>
<ul>
<li ng-class="{'active open': $state.includes('category')}"><a ui-sref="category.cat">Category</a></li>
</ul>
</nav>
<div class="row" style="padding-top:120px;" ui-view>
</div>
Here when I am clicking on the Category
link the above error is coming. My Plunkr code is here. How can I resolve this error?
Upvotes: 0
Views: 65
Reputation: 187
In your plunker, the link "category/manage_category" will use the "adminCatCategoryController" controller . It has some code :
dashboard.controller('adminCatCategoryController',function($scope,$http,$location,$window,$state,Upload,focusInputField){
})
I can't find any file that define "Upload", "focusInputField" as service/factory or constant . So when you inject them in here, angular can't detect them and throw error.
Remove or defined them will resolve your problem.
Hope it helpful for you ! Thanks !
Upvotes: 2