2017-10-05 32 views
0

我有一個角應用,其中i有一個app.run.js和app.controllers.js模塊時控制器,服務指令放入單獨的文件

以前我是使用一個main.js不可用的錯誤,應用程序工作正常,但現在,當我 分居控制器和run.js

我收到沒有模塊可用的錯誤。

Error: $injector:modulerr 
Module Error 

我到底做錯了什麼?

請參閱搗鼓代碼

<!DOCTYPE html> 
 
<html lang="en"> 
 

 
<head> 
 
    <title>Starfleet</title> 
 
    <meta charset="UTF-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> 
 
    <link rel="icon" href="http://webstandards.delhivery.com/favicon.ico"> 
 
    <link rel="stylesheet" href="https://webstandards.delhivery.com/2.1.0/libs/ws/delhivery.css"> 
 
    <link rel="stylesheet" href="styles/style.css"> 
 
</head> 
 

 
<body ng-app="starfleet-app" ng-controller="pageController as vm"> 
 
    
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script> 
 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.min.js"></script> 
 
    <script src="https://webstandards.delhivery.com/2.1.0/libs/ws/delhivery.js"></script> 
 
    <script src="scripts/app.run.js"></script> 
 
    <script src="scripts/controllers/app.page.controller.js"></script> 
 
    
 
</body> 
 

 
</html> 
 

 
This is my app.run.js 
 

 
angular.module('starfleetApp',['dlv-ng','ngRoute']); 
 
angular.module('starfleetApp').config(function($routeProvider) { 
 
    debugger; 
 
     $routeProvider 
 
      .when('/', { 
 
       templateUrl: './../partials/tracking.html' 
 
      }) 
 
      .when('/create', { 
 
       templateUrl: './../partials/createOrder.html' 
 
      }) 
 
      .when('/singleUpload', { 
 
       templateUrl: './../partials/singleUpload.html' 
 
      }) 
 
      .otherwise({ 
 
       redirectTo: '/' 
 
      }); 
 

 
    }); 
 
    
 
    
 
This is my app.page.controller.js 
 

 
angular.module("starfleetApp").controller('pageController', function($scope, $uibModal, $log, $document, $rootScope) { 
 

 

 
}); 
 
    
 

 
<!-- begin snippet: js hide: false console: true babel: false -->

回答

1

您是否嘗試過改變你的angular.module("starfleetApp")angular.module("starfleet-app")

根據自己的HTML和JS,你正在使用錯誤的模塊名稱。這可能會解決你的錯誤。

編輯

工作代碼 http://jsbin.com/komodukipe/edit?html,output

+0

感謝的人。有效。 但我有一個疑問,不要在html中使用分隔的命名空間,而在javascript中使用camelcase以避免應用程序名稱的角度。 –

+0

你的歡迎兄弟。我認爲你指的是指令命名。 –

+0

哦,是的。謝謝。 –

相關問題