honeyBack 2016-03-11 06:55 采纳率: 0%
浏览 1601
已结题

ionic angular 页面报错 ctrl 未定义

用angular做移动客户端页面,route代码如下,

angular.module('swpApp.question', ['ionic']).config(['$stateProvider', function($stateProvider) {
    $stateProvider
        .state('questionList', {
            url: '/questionList',
            cache:'false',
            resolve: {
                loginInfo:["$q",appLogin.loginToken],//用户登录信息
                spwItemListCacah:["$q",function($q){
                    return pageScroll.loadCacahData($q,"myQuestion");
                }]//缓存信息
            },
            templateUrl: "app/question/view/questionList.html",
            controller: 'QuestionListCtrl'
        })
        .state('questionDetail', {
          url: '/questionDetail/:question_id',
          cache:'false',
          resolve: {
              loginInfo:["$q",appLogin.loginToken]
          },
          templateUrl: "app/question/view/questionDetail.html",
          controller: 'QuestionDetailCtrl'
   })
}]);

在主页面跳往子页面时 报错:

 Error: [ng:areq] Argument 'QuestionDetailCtrl' is not a function, got undefined
http://errors.angularjs.org/1.4.3/ng/areq?p0=QuestionDetailCtrl&p1=not%20a%20function%2C%20got%20undefined
    at ionic.bundle.js:8900
    at assertArg (ionic.bundle.js:10602)
    at assertArgFn (ionic.bundle.js:10612)
    at ionic.bundle.js:17807
    at self.appendViewElement (ionic.bundle.js:52338)
    at Object.switcher.render (ionic.bundle.js:50456)
    at Object.switcher.init (ionic.bundle.js:50376)
    at self.render (ionic.bundle.js:52198)
    at self.register (ionic.bundle.js:52156)
    at updateView (ionic.bundle.js:57577)

各位大侠 知道是为什么么,是我QuestionDetailCtrl定义有问题么,仿照QuestionListCtrl定义的啊,QuestionListCtrl就么有问题。我是 新手,在线急等,帮帮忙
c币不多 了 ,不好意思

  • 写回答

1条回答

  • Z_pigeon 2017-05-10 08:37
    关注

    QuestionDetailCtrl有没有写具体内容,你这里只是说QuestionDetail这个页面会使用这个controller(名字而已),那有没有具体写方法是另外回事。如

     .controller('dealDetailCtrl', ['$scope',function($scope) {
    
    }])
    

    只定义,没有写方法就会报找不到的错误

    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛