如何在Angular中添加依赖于模块的依赖项列表?

时间:2017-01-16 15:53:29

标签: angularjs angular-bootstrap

我尝试使用angular-bootstrap-nav-tree库,但我无法添加&#39; angularBootstrapNavTree&#39;到我的模块的依赖项列表。有错误 "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"]
          }]      
     });

2 个答案:

答案 0 :(得分:0)

您实际上已将其添加到模块的依赖项列表中,而不是添加到控制器的依赖项中。

{{1}}

答案 1 :(得分:0)

你错过了你的合成器中的;},我修复了它:

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"]
          }];      
      } 
   });

此外,您可能忘记将angularBootstrapNavTree添加到模块依赖项中:

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