zoukankan      html  css  js  c++  java
  • Ionic Contoller类与Service类分开需要注意的问题

    看了别人的项目把Controller类和Service类都写在了app.js文件里面,这不符合我的风格,想把他们分开成单独的文件,确遇见以下错误提示:

    ionic.bundle.min.js:133 Error: [ng:areq] http://errors.angularjs.org/1.3.13/ng/areq?p0=appMainC&p1=not%20a%20function%2C%20got%20undefined
        at Error (native)
        at http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:37:417
        at Sb (http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:50:510)
        at tb (http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:51:78)
        at http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:106:331
        at http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:88:65
        at s (http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:38:408)
        at v (http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:87:438)
        at g (http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:82:299)
        at g (http://localhost:8100/lib/ionic/js/ionic.bundle.min.js:82:316)
    

     看后百思不得其解,Ionic网站给出的解决方法是:

    Error: ng:areq
    Bad Argument
    Argument 'AppMainController' is not a function, got undefined
    Description AngularJS often asserts that certain values will be present and truthy using a helper function. If the assertion fails, this error is thrown.
    To fix this problem, make sure that the value the assertion expects is defined and matches the type mentioned in the error.

      然而别没有看懂.......期间各种怀疑,各种测试,一下午时间就这样过去了,何其不幸.....

     晚饭过后,想到以前做的项目就怎么可以能,然后去对比以下,貌似发现了问题的所在 ,以前的代码:

    angular.module('ionicApp.controllers')
    

      现在的代码:

    angular.module("ionicApp.controllers",[])
    

      竟然是这样一个小小的地方,无语了.....

    或许暴露的问题是我对Ionic机制的理解还不够深刻,在此作为警戒。

     

  • 相关阅读:
    SpringBoot学习之配置Redis
    安全测试12使用nmap工具识别系统指纹信息
    安全测试11nmap扫描开放的端口
    安全测试17渗透攻击Mysql数据库服务
    安全测试18渗透攻击Tomcat服务
    安全测试16漏洞扫描工具Nikto详细使用教程
    实用且靠谱的18个免费引流推广方法
    安全测试15Maltego详细使用教程
    安全测试14ARP侦查工具Netdiscover
    统计本机tcp连接情况分离排查问题
  • 原文地址:https://www.cnblogs.com/crazyguo/p/5985815.html
Copyright © 2011-2022 走看看