javascript 如何在与 yeoman 的角度中包含 ngAnimate 依赖项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22789977/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to include ngAnimate dependency in angular with yeoman
提问by aurel
I am create an angular application using the combination of yeoman, gruntjs and bower. I installed my angular app with yo angular myapp
and then added few dependencies with bower and finally I would run grunt server
and start working.
我正在使用 yeoman、gruntjs 和 bower 的组合创建一个有角度的应用程序。我安装了我的 angular 应用程序,yo angular myapp
然后使用 bower 添加了一些依赖项,最后我会运行grunt server
并开始工作。
Only when I try to add the ng-animate
dependency, I get into problems. This dependency gets downloaded but its scripting tag does not get added into index.html
and the required reference does not get added into the karma.conf.js
file.
只有当我尝试添加ng-animate
依赖项时,我才会遇到问题。此依赖项已下载,但其脚本标记未添加到文件中index.html
,所需的引用也未添加到karma.conf.js
文件中。
I have tried to add these two references manually:
我试图手动添加这两个引用:
in the index.html
在里面 index.html
<script src="bower_components/angular-animate/angular-animate.js"></script>
and in karma/conf.js
并在 karma/conf.js
files: [
...
'app/bower_components/angular-animate/angular-animate.js',
...
],
But this only works if the grunt server
is already running. if I stop the server and re-run it again, the two reference that I have added manually vanish. How do I fix this issue?
但这仅在grunt server
已经运行的情况下才有效。如果我停止服务器并再次重新运行它,我手动添加的两个引用就会消失。我该如何解决这个问题?
Thanks
谢谢
采纳答案by Oscar
You can try one of the two following solutions:
您可以尝试以下两种解决方案之一:
- add it to you bower.json file as a dependency, then run
bower update
- 将其作为依赖项添加到您的 bower.json 文件中,然后运行
bower update
or
或者
- open terminal in you project directory and run:
bower install angular-animate
- 在您的项目目录中打开终端并运行:
bower install angular-animate
either one will persist it to your bower.json file and cause it to not be deleted when you run grunt server again.
任何一个都会将它保存到你的 bower.json 文件中,并在你再次运行 grunt server 时导致它不会被删除。
回答by Eduardo Dennis
You have to do this:
你必须这样做:
1. Install with bower:
1.用凉亭安装:
bower install angular-animate
2. Add a < script />to your index.html:
2. 将< script />添加到您的 index.html:
< script src="/bower_components/angular-animate/angular-animate.js"></script >
3. And add ngAnimate as a dependency for your app:
3. 并添加 ngAnimate 作为您的应用程序的依赖项:
angular.module('myApp', ['ngAnimate']);
See the ng-newsletter post on ngAnimatefor more information on these steps
有关这些步骤的更多信息,请参阅ngAnimate 上的 ng-newsletter帖子