[英]Checking Angular Dependency Injection
Is there a way that I can confirm that a module has loaded the correct dependencies? 有没有一种方法可以确认模块已加载正确的依赖关系? I have included ngAnimate as part of the module definition, but it does not "seem" to be loaded into the application upon run time. 我已经将ngAnimate包含在模块定义中,但是在运行时它不会“似乎”被加载到应用程序中。 There are a multitude of complexities in the environment I am working in so I want to find a clear way of knowing if ngAnimate has in fact been loaded or not. 我正在工作的环境中存在许多复杂性,因此我想找到一种明确的方法来了解ngAnimate是否实际上已加载。
angular.module('test', [
'ngAnimate',
'other',
'stuff'
]);
You can try to inject $animate into one of your controllers and if you get an injection error you know it hasn't loaded. 您可以尝试将$ animate注入到您的一个控制器中,如果遇到注入错误,您就知道它尚未加载。
You do know that ngAnimate needs to be loaded as a separate file, right? 您知道ngAnimate需要作为单独的文件加载,对吗?
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular-animate.min.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.