[英]Why can't Angular find my controller?
嘗試加載任何視圖時,出現“錯誤:ng:areq”錯誤。 我具有以下文件結構:
-app/modules
-- dashboard
--- views/ dashboard.html
--- controllers/ dashboard-ctrl.js
-app.js
我有一個包含所有控制器的模塊,稱為“ si.modules”。 我在主app.js模塊中將其添加為依賴項,如下所示:
var app = angular.module('xenon-app', [
'ngCookies',
'ngAnimate',
'ui.router',
'ui.bootstrap',
'oc.lazyLoad',
'xenon.controllers',
'xenon.directives',
'xenon.factory',
'xenon.factory.si',
'xenon.services',
'uiSwitch',
'angularUtils.directives.dirPagination',
'si.modules',
// Added in v1.3
'FBAngular',
//Added for image uploader
'angularFileUpload',
//ngtags input
'ngTagsInput',
]);
我也將控制器文件包含在index.html中,如下所示:
<script src="app/scripts/app.js"></script>
<script src="app/modules/Dashboard/dashboard-ctrl.js"></script>
我在這里做錯了什么?
包括:
<script src="app/modules/Dashboard/dashboard-ctrl.js"></script>
但是從您的項目結構來看,它應該是:
<script src="app/modules/dashboard/controllers/dashboard-ctrl.js"></script>
您缺少controllers
目錄
<script src="app/scripts/app.js"></script>
<script src="app/modules/Dashboard/dashboard-ctrl.js"></script>
應該是
<script src="app.js"></script>
<script src="app/modules/dashboard/controllers/dashboard-ctrl.js"></script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.