简体   繁体   中英

Angular-ui-router is deleted automatically

So, I do a basic project using yeoman. After I install it, I want to use Angular-ui-router, so I do 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. 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. I need that component. Can you guys help me how to fix this issue?

yeoman angular generator use wiredep for injecting bower components automatically. 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 .

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 install ui-router --save

run this one to save it on bower.json and then run

grunt serve

it will work...

Add --save Or --save-dev while installing bower components which will add your installed component to 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. So you no need to add bower components manually to index.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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