Javascript 从单个angularjs文件调用所有控制器

Javascript 从单个angularjs文件调用所有控制器,javascript,jquery,angularjs,ionic-framework,ngroute,Javascript,Jquery,Angularjs,Ionic Framework,Ngroute,我是Angularjs和Ionic的新手,我已经尝试了本论坛和其他地方提供的所有解决方案。我似乎不能让任何东西工作 我想开发一个应用程序,其主页设计为一组卡片(照片)。当点击一张卡片时,我们被引导到另一个页面。我阅读了关于ng view的文章,并尝试了一些教程,但没有一个对我有用 以下是一个例子: Index.html <!DOCTYPE html> <html ng-app="sampleApp"> <head>

我是Angularjs和Ionic的新手,我已经尝试了本论坛和其他地方提供的所有解决方案。我似乎不能让任何东西工作

我想开发一个应用程序,其主页设计为一组卡片(照片)。当点击一张卡片时,我们被引导到另一个页面。我阅读了关于ng view的文章,并尝试了一些教程,但没有一个对我有用

以下是一个例子:

Index.html

    <!DOCTYPE html>
       <html ng-app="sampleApp">
         <head>
            <meta charset="utf-8">
            <script src="js/app.js"></script>
            <script src="js/plugins/angular.js"></script>
            <script src="js/plugins/angular-route.js"></script>
            <title>AngularJS Routing example</title>
         </head>

        <body>

    <div class="container">
    <div class="row">
    <div class="col-md-3">
      <ul class="nav">
        <li><a href="#AddNewOrder"> Add New Order </a></li>
        <li><a href="#ShowOrders"> Show Order </a></li>
      </ul>
    </div>
    <div class="col-md-9">
        <div ng-view></div>
    </div>
    </div>
    </div>
  </body>
</html>

add_order.html
添加新订单
{{message}}
我得到的错误是:

> > ReferenceError: angular is not defined  app.js:2:5 Error: [$injector:modulerr] Failed to instantiate module sampleApp due to:
> [$injector:nomod] Module 'sampleApp' is not available! You either
> misspelled the module name or forgot to load it. If registering a
> module ensure that you specify the dependencies as the second
> argument.
> http://errors.angularjs.org/1.2.9/$injector/nomod?p0=sampleApp
> minErr/<@http://localhost:8100/js/plugins/angular.js:78:12
> module/<@http://localhost:8100/js/plugins/angular.js:1529:1
> ensure@http://localhost:8100/js/plugins/angular.js:1454:38
> module@http://localhost:8100/js/plugins/angular.js:1527:1
> loadModules/<@http://localhost:8100/js/plugins/angular.js:3622:22
> forEach@http://localhost:8100/js/plugins/angular.js:303:7
> loadModules@http://localhost:8100/js/plugins/angular.js:3616:5
> createInjector@http://localhost:8100/js/plugins/angular.js:3556:11
> bootstrap/doBootstrap@http://localhost:8100/js/plugins/angular.js:1299:20
> bootstrap@http://localhost:8100/js/plugins/angular.js:1314:1
> angularInit@http://localhost:8100/js/plugins/angular.js:1263:5
> @http://localhost:8100/js/plugins/angular.js:20555:5
> trigger@http://localhost:8100/js/plugins/angular.js:2342:7
> createEventHandler/eventHandler/<@http://localhost:8100/js/plugins/angular.js:2613:7
> forEach@http://localhost:8100/js/plugins/angular.js:310:11
> createEventHandler/eventHandler@http://localhost:8100/js/plugins/angular.js:2612:5
>ReferenceError:angular未定义应用程序。js:2:5错误:[$injector:modulerr]未能实例化模块sampleApp,原因是:
>[$injector:nomod]模块“sampleApp”不可用!你也是
>模块名称拼写错误或忘记加载。如果注册
>模块确保将依赖项指定为第二个
>争论。
> http://errors.angularjs.org/1.2.9/$injector/nomod?p0=sampleApp
>矿工/模块/ensure@http://localhost:8100/js/plugins/angular.js:1454:38
> module@http://localhost:8100/js/plugins/angular.js:1527:1
>加载模块/forEach@http://localhost:8100/js/plugins/angular.js:303:7
> loadModules@http://localhost:8100/js/plugins/angular.js:3616:5
> createInjector@http://localhost:8100/js/plugins/angular.js:3556:11
>引导/doBootstrap@http://localhost:8100/js/plugins/angular.js:1299:20
> bootstrap@http://localhost:8100/js/plugins/angular.js:1314:1
> angularInit@http://localhost:8100/js/plugins/angular.js:1263:5
> @http://localhost:8100/js/plugins/angular.js:20555:5
> trigger@http://localhost:8100/js/plugins/angular.js:2342:7
>createEventHandler/eventHandler/forEach@http://localhost:8100/js/plugins/angular.js:310:11
>createEventHandler/eventHandler@http://localhost:8100/js/plugins/angular.js:2612:5
编辑

我从app.js中的模块依赖项中删除了“IONAL”。
现在,第一个链接“添加顺序”起作用,但第二个链接“显示顺序”不起作用。

我认为您应该更改库的顺序:

<head>
     <meta charset="utf-8">
     <script src="js/plugins/angular.js"></script>
     <script src="js/plugins/angular-route.js"></script>
     <script src="js/app.js"></script>    
     <title>AngularJS Routing example</title>
</head>

AngularJS路由示例

您试图链接模块声明,但每个声明都有一个分号。我更改了它。还是同样的问题。你能创建一个JSFIDLE/plunkstill吗problem@Hana你的应用程序在“js/app.js”或“app.js”中吗。因为您同时引用了它们。同样,您在“js/plugins/Angular.js”中引用Angular,然后从CDN(一个旧版本)引用Angular。你需要对你的资料进行认真清理,才能让任何人给你一个不只是猜测的答案。在html末尾,你复制angular和应用程序库,这可能是原因。仍然不起作用’错误:[$injector:modulerr]未能实例化模块sampleApp,原因是:[$injector:modulerr]无法实例化模块ionic,原因是:[$injector:nomod]模块“ionic”不可用!您要么拼错了模块名,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。“我没有看到您使用的是名为ionic的模块,您应该在脚本中包含该库。”。大概是这样的:
> > ReferenceError: angular is not defined  app.js:2:5 Error: [$injector:modulerr] Failed to instantiate module sampleApp due to:
> [$injector:nomod] Module 'sampleApp' is not available! You either
> misspelled the module name or forgot to load it. If registering a
> module ensure that you specify the dependencies as the second
> argument.
> http://errors.angularjs.org/1.2.9/$injector/nomod?p0=sampleApp
> minErr/<@http://localhost:8100/js/plugins/angular.js:78:12
> module/<@http://localhost:8100/js/plugins/angular.js:1529:1
> ensure@http://localhost:8100/js/plugins/angular.js:1454:38
> module@http://localhost:8100/js/plugins/angular.js:1527:1
> loadModules/<@http://localhost:8100/js/plugins/angular.js:3622:22
> forEach@http://localhost:8100/js/plugins/angular.js:303:7
> loadModules@http://localhost:8100/js/plugins/angular.js:3616:5
> createInjector@http://localhost:8100/js/plugins/angular.js:3556:11
> bootstrap/doBootstrap@http://localhost:8100/js/plugins/angular.js:1299:20
> bootstrap@http://localhost:8100/js/plugins/angular.js:1314:1
> angularInit@http://localhost:8100/js/plugins/angular.js:1263:5
> @http://localhost:8100/js/plugins/angular.js:20555:5
> trigger@http://localhost:8100/js/plugins/angular.js:2342:7
> createEventHandler/eventHandler/<@http://localhost:8100/js/plugins/angular.js:2613:7
> forEach@http://localhost:8100/js/plugins/angular.js:310:11
> createEventHandler/eventHandler@http://localhost:8100/js/plugins/angular.js:2612:5
<head>
     <meta charset="utf-8">
     <script src="js/plugins/angular.js"></script>
     <script src="js/plugins/angular-route.js"></script>
     <script src="js/app.js"></script>    
     <title>AngularJS Routing example</title>
</head>