简体   繁体   English

Angular-ui-router自动删除

[英]Angular-ui-router is deleted automatically

So, I do a basic project using yeoman. 因此,我使用yeoman做一个基础项目。 After I install it, I want to use Angular-ui-router, so I do bower install ui-router . 安装后,我想使用Angular-ui-router,所以我会bower install ui-router I injected <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script> in my index.html and do everything as explained in many tutorials. 我在index.html中注入了<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script> ,并按照许多教程中的说明进行了所有操作。 But the problem came when I do the grunt serve , the <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script> which I was injected in index.html is being deleted automatically. 但是问题出在我做grunt serve ,被注入index.html的<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>自动删除。 I need that component. 我需要那个组件。 Can you guys help me how to fix this issue? 你们能帮我解决这个问题吗?

yeoman angular generator use wiredep for injecting bower components automatically. 约曼角发生器使用wiredep自动注入凉亭组件。 So first of all you should not add them manually it will all deleted with grunt serve as wiredep clean that block and inject registered bower components . 因此,首先您不应该手动添加它们,它们会被grunt删除,并用作有线清理该块并注入已注册的Bower组件

So every bower components should be on your bower.json file but I assume you missing ui-router you can add it to your bower.json manually or you can add --save on your bower command to save it to bower.json automatically. 因此,每个Bower组件都应位于bower.json文件上,但我假设您缺少ui-router ,可以将其手动添加到bower.json中,也可以在bower命令上添加--save以将其自动保存到bower.json中。

bower install ui-router --save

run this one to save it on bower.json and then run 运行此文件以将其保存在bower.json上,然后运行

grunt serve

it will work... 它会工作...

Add --save Or --save-dev while installing bower components which will add your installed component to bower.json. 在安装Bower组件时添加--save或--save-dev,这会将已安装的组件添加到bower.json中。

bower install ui-router --save

once you installed bower components by --save then grunt serve will add all your bower components from bower.json to index.html file. 通过--save安装Bower组件后,grunt serve会将所有Bower.json文件从Bower.json添加到index.html文件。 So you no need to add bower components manually to index.html 因此,您无需手动将Bower组件添加到index.html

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM