Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove angularjs route with yeoman

with Yeoman I can add a route and the controller with

yo angular:route myroute

is there a way to remove route and controller with Yeoman?

like image 455
markus Avatar asked Dec 13 '13 23:12

markus


2 Answers

I faced a similar need to remove controller ... but from the docs I came to know that there does not seem to exist an api for deleting .

refer : https://github.com/yeoman/generator-angular

But to help you out for the time being I will tell what I did .... From the docs I know which are the files created for each command . so delete those files alone to get rid of the files produces by the yeoman operation .

for example

yo angular:route myroute

creates 3 files

1)    app/scripts/controllers/myroute.js              (controller)

2)    app/views/myroute.html                          (view)

3)    app/test/spec/controllers/myroute.js            (testing the controller)

so delete these three files alone .

for others namely

yo angular:controller user                app/scripts/controllers/user.js

yo angular:directive myDirective          app/scripts/directives/myDirective.js

yo angular:filter myFilter                app/scripts/filters/myFilter.js

yo angular:view user                      app/views/user.html

yo angular:service myService              app/scripts/services/myService.js

yo angular:decorator serviceName          app/scripts/decorators/serviceNameDecorator.js

yo angular:controller user --coffee       app/scripts/controller/user.coffee 

Note : also don't forget to delete the test files inside app/test/spec which are for testing

How can we confirm that the feature may not exists ?

from source code for example for controller

https://github.com/yeoman/generator-angular/blob/master/controller/index.js

The api has only Generator.prototype.createControllerFiles so nothing for removeControllerFiles so we should be correct in saying that the feature doesn't exist at present .

like image 159
Harish Kayarohanam Avatar answered Oct 22 '22 21:10

Harish Kayarohanam


There is no API for deleting


Like the answer above mentions you will have to delete in various places.

Main Location

1)    app/scripts/controllers/myroute.js              (controller)

2)    app/views/myroute.html                          (view)

3)    app/test/spec/controllers/myroute.js            (testing the controller)

Bonus locations

4) app/scripts/app.js       (delete from app controller)
5)test/spec/controllers/myroute.js   (testing the controller) mine was outside the app dirtectory
like image 45
Eduardo Dennis Avatar answered Oct 22 '22 19:10

Eduardo Dennis