Search code examples
angularjsangular-bootstrap

How to add dependency to module's list of dependencies in Angular?


I'm trying to use angular-bootstrap-nav-tree library, but I'cant add 'angularBootstrapNavTree' to my module's list of dependencies. There is error "Unknown provider: angularBootstrapNavTreeProvider <- angularBootstrapNavTree"

 angular.
  module('myApp').
  component('treeList', {
      template: ' <abn-tree tree-data="my_data"></abn-tree>',
      controller: function MyCtrl($http, $scope, dataContext, angularBootstrapNavTree) {              
          $scope.my_data = [{
              label: 'Languages',
              children: ['Jade','Less','Coffeescript'],
              classes: ["special", "red"]
          }]      
     });

Solution

  • You missed a ; and a } in your synthax, I fixed it:

    angular.
      module('myApp').
      component('treeList', {
          template: '<abn-tree tree-data="my_data"></abn-tree>',
          controller: function MyCtrl($http, $scope, dataContext, angularBootstrapNavTree) {              
              $scope.my_data = [{
                  label: 'Languages',
                  children: ['Jade','Less','Coffeescript'],
                  classes: ["special", "red"]
              }];      
          } 
       });
    

    Furthermore, you may have forgot to add angularBootstrapNavTree to your module dependencies:

    angular.module('myApp', ['angularBootstrapNavTree']);