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


    今天把用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 是大小写敏感,这里定义的控制器名要与路由中定义的控制器名大小写一致

  • 相关阅读:
    关于使用stanfordcorenlp一直运行不报错的解决方法
    小程序项目报错
    小程序项目学习笔记
    如何将知网下载的caj文件转换为pdf文件
    干眼症治疗方法
    事务基础
    Android的四大组件
    异步任务AsyncTask使用解析
    Android Service的生命周期
    2016 校招, Android 开发,一个本科应届的坎坷求职之路(转)
  • 原文地址:https://www.cnblogs.com/felixnet/p/8035789.html
Copyright © 2020-2023  润新知