Error: [ng:areq] Argument ‘AppCtrl’ is not …

2018-06-24 01:03:24来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

今天把用ionic做一个案例,和ionic示例项目差不多,只是用requirejs分离了controller,但是一直报错

Error: [ng:areq] Argument ‘AppCtrl’ is not a function, got undefined

define(function (require) {
  'use strict';
  var controllers = angular.module('starter.controllers', []);
  controllers.controller('appCtrl',require('controllers/appController'));
  controllers.controller('dashCtrl',require('controllers/dashController'));
  controllers.controller('gameCtrl',require('controllers/gameController'));
  controllers.controller('meCtrl',require('controllers/meController'));
  controllers.controller('infoCtrl',require('controllers/infoController'));
  controllers.controller('playListCtrl',require('controllers/playListController'));return controllers;
});

经过一番折腾还是没能解决。后来我细分析,我的控制器叫appCtrl,错误信息中怎么是AppCtrl,我试着将名称首字母大写,卧槽,居然通过了

define(function (require) {
  'use strict';
  var controllers = angular.module('starter.controllers', []);
  controllers.controller('AppCtrl',require('controllers/appController'));
  controllers.controller('DashCtrl',require('controllers/dashController'));
  controllers.controller('GameCtrl',require('controllers/gameController'));
  controllers.controller('MeCtrl',require('controllers/meController'));
  controllers.controller('InfoCtrl',require('controllers/infoController'));
  controllers.controller('PlayListCtrl',require('controllers/playListController'));
  return controllers;
});

再在网上搜,原来 ionic 的 ui-router 是大小写敏感,这里定义的控制器名要与路由中定义的控制器名大小写一致

 

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:.9-浅析webpack源码之NodeEnvironmentPlugin模块总览

下一篇:Js中for循环的阻塞机制