我寫了一個模塊,以保持我所有的輔助功能(scripts/apps.js)
軌跡:JS錯誤與角JS模塊
angular.module('app', ['ngResource']).run(function($scope){
$scope.UTIL = {
setup_pod_variables: function (pods){...}
...
});
我試圖調用從另一個目錄中定義我的控制器的輔助函數:腳本/控制器/Dashboard.js:
scope.UTIL.setup_pod_variables(pods)
;
我已經包含了其他模塊:
var pods = angular.module('app', []);
但似乎我仍然得到一個錯誤:
TypeError: Cannot read property 'setup_pod_variables' of undefined
at new <anonymous> (file:///Users/simon_zhu/Documents/nautilus/app/scripts/controllers/Dashboard.js:16:12)
at d (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:30:346)
at Object.instantiate (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:30:475)
at file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:61:228
at file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:48:320
at q (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:7:380)
at W (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:48:186)
at f (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:42:268)
at f (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:42:285)
at f (file:///Users/simon_zhu/Documents/nautilus/app/scripts/angular.min.js:42:285)
什麼想法?