为什么模块没有在离子+角度js中实例化

时间:2015-03-27 06:54:14

标签: angularjs angularjs-directive angularjs-scope ionic-framework ionic

我正在尝试创建第一页。我已经实例化了我的模块,但是我收到了实例化模块的错误。这是我的错误

Uncaught Error: [$injector:modulerr] Failed to instantiate module app1 due to:
Error: [$injector:modulerr] Failed to instantiate module app1.Firstpage due to:
ReferenceError: loginController is not defined
    at routerChange (http://127.0.0.1:1139/www/js/Firstpage/route.js:9:41)
    at Object.invoke (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12110:17)
    at runInvokeQueue (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12016:35)
    at http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12025:11
    at forEach (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:8248:20)
    at loadModules (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12006:5)
    at http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12023:40
    at forEach (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:8248:20)
    at loadModules (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12006:5)
    at createInjector (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:11932:11)
http://errors.angularjs.org/1.3.13/$injector/modulerr?p0=app1.Firstpage&p1=…2F127.0.0.1%3A1139%2Fwww%2Flib%2Fionic%2Fjs%2Fionic.bundle.js%3A11932%3A11)
    at REGEX_STRING_REGEXP (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:7988:12)
    at http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12045:15
    at forEach (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:8248:20)
    at loadModules (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12006:5)
    at http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12023:40
    at forEach (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:8248:20)
    at loadModules (http://127.0.0.1:1139/www/lib/ionic/js/ionic.bundle.js:12006:5)
    at createInjector (http://127.0.0.1:1139/www/lib/ionic/js/ionic.

我喜欢这个

(function(){
    'use strict',
    angular.module('app1.Firstpage',['ionic']);

})();

这是我的代码

https://dl.dropbox.com/s/zipm6g0ewqf7xg4/ionic_web.zip?dl=0

index.html中的

**<html ng-app="app1">**

router.js

(function(){
  'use strict'  
   angular.module('app1.Firstpage').config(routerChange);
    routerChange.$inject=['$stateProvider', '$urlRouterProvider'];
    function routerChange($stateProvider,$urlRouterProvider){
        $stateProvider.state('login',{
                             url:'/login',
                             templateUrl:"js/Firstpage/template/login.html",
                             controller:loginController

        })

        $urlRouterProvider.otherwise('/login')
    }


})();

1 个答案:

答案 0 :(得分:-1)

只需在router.js下方加controller.js即可。当路由器执行时,没有控制器可以找到它。