2017-01-16 54 views
0

我正在嘗試使用angular-bootstrap-nav-tree庫,但我無法將'angularBootstrapNavTree'添加到我的模塊的依賴關係列表中。有錯誤 "Unknown provider: angularBootstrapNavTreeProvider <- angularBootstrapNavTree"如何在Angular中添加依賴到模塊的依賴列表?

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

有您是否正確地包含了以下文件? ** abn_tree_directive.js **, ** abn_tree.css ** – Korte

+0

@Korte,是的,我有。 –

回答

0

你錯過了;並在synthax一個},我固定它:

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']); 
0

您實際上已經將其添加到依賴您模塊列表,而不是在控制器的依賴。

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