markus
markus

Reputation: 267

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?

Upvotes: 12

Views: 8365

Answers (3)

M.W. Felker
M.W. Felker

Reputation: 4823

If you are using git, this can easily be accomplished by using the clean tool:

git clean -f

The above will remove all untrack files in your working branch. In the case that yo modifies tracked files, you can just do the following:

git checkout file1/ file2

Or all of them

git checkout .

Upvotes: 0

Eddie Martinez
Eddie Martinez

Reputation: 13910

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

Upvotes: 2

Harish Kayarohanam
Harish Kayarohanam

Reputation: 4024

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 .

Upvotes: 18

Related Questions