0

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?

5
  • Please provide your jsfiddle. Commented Aug 31, 2016 at 10:50
  • Where is adminCatCategoryController ? Commented Aug 31, 2016 at 10:51
  • 1
    something got messed with UploadProvider Commented Aug 31, 2016 at 10:52
  • Please check my updated post. Commented Aug 31, 2016 at 10:53
  • @Loading.. : Please check my post again. Commented Aug 31, 2016 at 10:56

1 Answer 1

2

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 !

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for detecting this type error.Its working now.

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.