2017-03-01 301 views
0

目前我有我的應用斷裂問題由於Error: $injector:modulerr Module Error

完整的錯誤是:

Failed to instantiate module app due to: 
    Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: 
Error: [$injector:modulerr] Failed to instantiate module JobCtrl due to: 
Error: [$injector:nomod] Module 'JobCtrl' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument. 
http://errors.angularjs.org/1.6.2/$injector/nomod?p0=JobCtrl 
    at http://ep-dev3/CPDManagement/app/Vendor/angular.js:69:20 
    at http://ep-dev3/CPDManagement/app/Vendor/angular.js:2188:31 
    at ensure (http://ep-dev3/CPDManagement/app/Vendor/angular.js:2112:46) 
    at module (http://ep-dev3/CPDManagement/app/Vendor/angular.js:2186:24) 
    at http://ep-dev3/CPDManagement/app/Vendor/angular.js:4757:36 
    at forEach (http://ep-dev3/CPDManagement/app/Vendor/angular.js:358:34) 
    at loadModules (http://ep-dev3/CPDManagement/app/Vendor/angular.js:4741:13) 
    at http://ep-dev3/CPDManagement/app/Vendor/angular.js:4758:54 
    at forEach (http://ep-dev3/CPDManagement/app/Vendor/angular.js:358:34) 
    at loadModules (http://ep-dev3/CPDManagement/app/Vendor/angular.js:4741:13) 
http://errors.angularjs.org/1.6.2/$injector/modulerr? 

我ui.bootstrap在兩者的相關性我的app.js和我的控制器。當我嘗試從我的控制器中刪除依賴項時,應用程序中斷。如果我離開它,它運行良好,但給我添加服務和指令的問題。

app.js:

angular.module('app', 
    [ 
     'JobCtrl', 
     'JobSvc', 
     'WebsiteCtrl', 
     'WebsiteSvc', 
     'myClientCtrl', 
     'ClientSvc', 
     'MediaCompanyCtrl', 
     'MediaCompanySvc', 
     'PageAlertSvc', 
     'ui.bootstrap', 
     'Common' 
    ] 
); 

控制器:

angular.module('app') 
    .controller('JobCtrl', 
      [ 
       'JobService', 
       'WebsiteService', 
       'MediaCompanyService', 
       'ProductService', 
       '$scope', 
       '$uibModal', 
       'PageAlertService', 
       function (JobService, WebsiteService, MediaCompanyService, 
        ProductService, $scope, $uibModal,PageAlertService){ 
            /** Stuff in my controller **/ 
      }]); 

EDIT顯示源

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title>@ViewBag.Title - CPD Management Tool</title> 
    <script src="~/app/Vendor/angular.min.js"></script> 
    <script src="~/Scripts/ui-bootstrap-tpls-2.5.0.min.js"></script> 
    @Styles.Render("~/Content/css") 
    @Scripts.Render("~/bundles/modernizr") 

</head> 
<body> 
@if (User.Identity.IsAuthenticated) 
{ 
    <div class="navbar navbar-inverse navbar-fixed-top"> 
     <div class="container"> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 

       @Html.ActionLink("Clear Path Direct", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" }) 
      </div> 
      <div class="navbar-collapse collapse"> 
       @if (User.IsInRole("Admin")) 
       { 
       <ul class="nav navbar-nav"> 
        <li class="dropdown"> 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" 
          aria-haspopup="true" aria-expanded="false">Tools<span class="caret"></span></a> 
         <ul class="dropdown-menu"> 
          <li class="text-center">@Html.ActionLink("Media Jobs", "Index", "MediaJobs")</li> 
          <li class="text-center">Order Processing</li> 
          <li class="text-center">Media Reporting</li> 
         </ul> 
        </li> 
        <li class="dropdown"> 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" 
          aria-haspopup="true" aria-expanded="false">Manage<span class="caret"></span></a> 
         <ul class="dropdown-menu"> 
          <li class="text-center">@Html.ActionLink("Manage Clients", "Index", "Clients")</li> 
          <li class="text-center">@Html.ActionLink("Manage Media Companies", "Index", "MediaCompanies")</li> 
          <li class="text-center">@Html.ActionLink("Manage Websites", "Index", "Websites")</li> 
         </ul> 
        </li> 

       </ul> 
       } 
       @Html.Partial("_LoginPartial") 

      </div> 
     </div> 
    </div> 
       } 
    <div class="container body-content"> 
     @RenderBody() 
     <!-- 
     <footer> 
      <p>&copy; @DateTime.Now.Year - CPD Management Tool</p> 
     </footer> 
      --> 
    </div> 

    @Scripts.Render("~/bundles/jquery") 
    @Scripts.Render("~/bundles/bootstrap") 
    <!--angular scripts--> 
    @Scripts.Render("~/bundles/Angular") 
    <!-- ----> 
    @RenderSection("scripts", required: false) 
</body> 
</html> 

where I am bring in sources

爲什麼我的應用程序運行時,我的控制器:

angular.module('app', ['ui.bootstrap']).controller('JobCtrl', 
     [ 
      'JobService', 
      'WebsiteService', 
      'MediaCompanyService', 
      'ProductService', 
      '$scope', 
      '$uibModal', 
      'PageAlertService', 
      function (JobService, WebsiteService, MediaCompanyService, 
       ProductService, $scope, $uibModal,PageAlertService) 

,並打破時,我有它喜歡:

angular.module('app').controller('JobCtrl', 
    [ 
     'JobService', 
     'WebsiteService', 
     'MediaCompanyService', 
     'ProductService', 
     '$scope', 
     '$uibModal', 
     'PageAlertService', 
     function (JobService, WebsiteService, MediaCompanyService, 
      ProductService, $scope, $uibModal,PageAlertService) 

幫助將非常感激!

+0

? – Sajeetharan

+0

我們可以看到你在你的html中加載你的js嗎? –

+0

我想能夠使用ui.bootstrap,但如果依賴項位於app.js依賴項列表中,我仍然可以使用它,對吧? – DDelgro

回答

0

我遇到的問題是我正在導入應用程序模塊(app.js)中的所有控制器和服務。謝謝@Claies向我指出這一點。

錯誤:

 angular.module('app', 
    [ 
     'JobCtrl', 
     'JobSvc', 
     'WebsiteCtrl', 
     'WebsiteSvc', 
     'myClientCtrl', 
     'ClientSvc', 
     'MediaCompanyCtrl', 
     'MediaCompanySvc', 
     'PageAlertSvc', 
     'ui.bootstrap', 
     'Common' 
    ] 
); 

右:

angular.module('app', ['ui.bootstrap']); 
要刪除的引導和相關的東西