2016-02-10 44 views
0

我有一個由模塊化angularjs子應用程序組成的項目。 子應用程序相對於根應用程序文件夾駐留在它們自己的文件夾中。 問題是我想通過涼亭包括一個外部模塊(衛星)。該模塊已正確下載,並且通過gulp/wiredep將bower組件注入到html中。迄今爲止都很好。

與控制器的應用程序的結構如下:

(function() { 
'use strict'; 

angular 
    .module('foo.bar') 
    .filter('orderObjectBy', function() { 
     return function (input, attribute) { 
      if (!angular.isObject(input)) return input; 

      var array = []; 
      for (var objectKey in input) { 
       array.push(input[objectKey]); 
      } 

      array.sort(function (a, b) { 
       a = parseInt(a[attribute]); 
       b = parseInt(b[attribute]); 
       return a - b; 
      }); 
      return array; 
     } 
    }) 
    .controller('FoobarController', FoobarController); 

FoobarController.$inject = ['logger', '$q', 'dataservice', '$stateParams', 'fooBarHandler', '$location', 'satellizer']; 
/* @ngInject */ 
function FoobarController(logger, $q, dataservice, $stateParams, fooBarHandler, $location, $authProvider) { 
    var vm = this; 
    fooBarHandler.includeIn(vm, dataservice); 

    vm.authorize = authorize; 


    }   
} 

問題是,角度保持說satellizer是未知提供商(未知提供商:satellizerProvider < - satellizer < - FooBarController) 爲爲了簡潔起見,我省略了很多來自控制器實現的代碼。

我也嘗試要連接經由陣列依賴性的依賴性像這樣:

angular 
    .module('foo.bar', ['satellizer']) 
    .filter('orderObjectBy', function() { 
     return function (input, attribute) { 
      if (!angular.isObject(input)) return input; 

      var array = []; 
      for (var objectKey in input) { 
       array.push(input[objectKey]); 
      } 

      array.sort(function (a, b) { 
       a = parseInt(a[attribute]); 
       b = parseInt(b[attribute]); 
       return a - b; 
      }); 
      return array; 
     } 
    }) 

但仍沒有運氣。

+0

試試這個'angular.module( 'foo.bar',[ 'satellizer'])' –

+0

希望你也在你的html文件中導入了衛星。 – dendimiiii

+0

是的,我在我的HTML文件中導入衛星。通過基於bower.json的gulp構建連線。 我也試過包括通過陣列依賴的衛星,但然後衛星變量是undefined – MDemmers

回答

2

得到它的工作。 通過挖掘衛星源後,我意識到我需要從提供商注入。衛星已將其提供商定義爲'$ auth'。所以,以後我改了行

FooBarController.$inject = ['logger', '$q', 'dataservice', '$stateParams', 'fooBarHandler', '$location', 'satellizer]; 

FooBarController.$inject = ['logger', '$q', 'dataservice', '$stateParams', 'fooBarHandler', '$location', '$auth]; 

它的工作

相關問題