Remove angularjs route with yeoman

markus picture markus · Dec 14, 2013 · Viewed 8.3k times · Source

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?

Answer

Harish Kayarohanam picture Harish Kayarohanam · Dec 14, 2013

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 .