2016-05-17 114 views
3

我有以下app.js及其無法使用模塊調用該應用程序。文件夾結構和代碼的附截圖:無法實例化應用程序

core.module.js:

(function() { 
 
    'use strict'; 
 

 
    angular 
 
     .module('app.core'); 
 
})();

(function() { 
 
    'use strict'; 
 
    
 
    angular 
 
     .module('app', [ 
 
      'ngRoute', 
 
      'ngCookies', 
 
      'ngAnimate', 
 
      'ngResource', 
 
      'ngCookies', 
 
      'ngTouch', 
 
      'app.core', 
 
      'app.events' 
 
     ]) 
 
     .config(config); 
 
     
 
    config.$inject = ['$routeProvider', '$locationProvider', '$httpProvider']; 
 
    function config($routeProvider, $locationProvider, $httpProvider) { 
 
     $routeProvider 
 
      .when('/', {..}..

Uncaught Error: [$injector:nomod] Module 'app.core' 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.
enter image description here

回答

5

您需要第二個參數angular.module();

參見Document

//創建一個新的模塊

變種Mymodule中= angular.module( 'Mymodule中',[]);

angular 
    .module('app.core',[]); 
0
  1. angular.module( 'app.core',[])是一個沒有任何模塊依賴創建一個新的模塊。
  2. angular.module('app.core')將檢索名爲app.core的現有模塊。

因此要創建角度模塊,您必須編寫angular.module('app.core',[])。

+0

我已經完成了這個工作,仍然給了我同樣的錯誤,並且還更新了它的屏幕截圖 - 未知提供者ServiceFactory! – Smitha

+0

嘗試了所有這些,沒有幫助! – Smitha

相關問題