简体   繁体   English

我应该按什么顺序导入我的 Angular 文件?

[英]In which order should I import my Angular files?

Angular app.js Angular 应用程序.js

(function () {
    angular
        .module("myApp", [
            'ngRoute',
            'ui.tree',
            'ngAnimate',            
            'ngMaterial'
        ]);
})();

On the index.html , the order of libraries import is:index.html 上,库导入的顺序是:

  1. angular.min.js angular.min.js
  2. angular-route.min.js angular-route.min.js
  3. angular-ui-tree.min.js angular-ui-tree.min.js
  4. jquery.min.js jquery.min.js
  5. bootstrap.min.js bootstrap.min.js
  6. angular-animate.min.js angular-animate.min.js
  7. angular-aria.min.js angular-aria.min.js
  8. angular-material.min.js angular-material.min.js

I'm getting this error:我收到此错误:

Error: $injector:unpr Unknown Provider错误:$injector:unpr 未知提供者

The order should be:顺序应该是:

  1. First import Angular ( angular.min.js ).首先导入 Angular ( angular.min.js )。

  2. Import Angular files: controllers, services, directives...导入 Angular 文件:控制器、服务、指令...

  3. Import others JS files导入其他JS文件

The order between Angular files does not matter ( eg: you can import services before controllers ). Angular 文件之间的顺序无关紧要(例如:您可以在控制器之前导入服务)。


In your case, a solution could be:在您的情况下,解决方案可能是:

  1. angular.min.js angular.min.js
  2. angular-route.min.js angular-route.min.js
  3. angular-ui-tree.min.js angular-ui-tree.min.js
  4. angular-animate.min.js angular-animate.min.js
  5. angular-aria.min.js angular-aria.min.js
  6. angular-material.min.js angular-material.min.js
  7. jquery.min.js jquery.min.js
  8. bootstrap.min.js bootstrap.min.js

Note: I don't see any controllers in your files, don't forget it!注意:我在你的文件中没有看到任何控制器,不要忘记它!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为了将swiper正确地加载到jQuery Mobile中,我应该按照哪个顺序正确放置javascript文件,我应该使用哪个页面事件? - In which order do I exactly place the javascript files in order for swiper to load properly with jQuery Mobile and what page event should I use? 我应该用哪种方式导入 React? - Which way should I import React? React 图标:我应该使用哪个导入? - React icons: Which import should I use? Meteor的顺序包括我的js文件 - In which order Meteor include my js files 将javascript库导入到我在Angular2项目中使用的自定义javascript文件中 - Import a javascript library into a custom javascript file which I use in my Angular2 project 我应该将Jquery文件放在我的Web服务器上,还是只通过jquery.com在我的PHP文件中引用它们,哪个更好? - Should I place Jquery files on my web server or just refer to them via jquery.com in my PHP files, which is better? 我应该将MVC视图专用的javascript文件放在哪个文件夹中? - Which folder(s) should I put my MVC view-specific javascript files in? 我应该在我的 jQuery 中使用哪个类? - Which class should I use in my jQuery? 我想学习,为什么:页脚导入应该发生在导入组件/菜单导入/订单之前 - I want to learn, why: Footer` import should occur before import of `components/Menu` import/order 我应该将我的 javascript 分成多个文件吗? - Should I split my javascript into multiple files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM