generator-angular-fullstack icon indicating copy to clipboard operation
generator-angular-fullstack copied to clipboard

Controller path for nested route have duplicated directory name

Open yoshiokatsuneo opened this issue 11 years ago • 8 comments

When I use "angular-fullstack:route" or "angular-fullstack:controller" for pathname like "main/sub", created filename is like "main/sub/main/sub.js". It should be like "main/sub/sub.js".

$ yo angular-fullstack:route main/sub
? Where would you like to create this route? client/app/ ? What will the url of your route be? /main/sub create client/app/main/sub/main/sub.js create client/app/main/sub/main/sub.controller.js create client/app/main/sub/main/sub.controller.spec.js create client/app/main/sub/main/sub.html create client/app/main/sub/main/sub.scss

$ yo angular-fullstack:controller main/sub2 ? Where would you like to create this controller? client/app/ create client/app/main/sub2/main/sub2.controller.js create client/app/main/sub2/main/sub2.controller.spec.js

yoshiokatsuneo avatar Jun 24 '15 05:06 yoshiokatsuneo

You're using the generator command in the incorrect folder.

Maybe you must use the command in the root directory of the project

You can use " pwd ", to know your current directory

Links: pwd command: http://unixhelp.ed.ac.uk/CGI/man-cgi?pwd

equero-old avatar Jun 24 '15 13:06 equero-old

@equero I'm using "yo" command at the project root. The thing is, "yo angular-fullstack:route NAME" create file like client/app/NAME/NAME.js, regardless of whether NAME is pure basename or pathname containing "/". If NAME is "post", generated filename is "client/app/post/post.js". (It is OK.) If NAME is "main/post", generated filename is "client/app/main/post/main/post.js". (It is not OK. "client/app/main/post/post.js" should be generated.)

Doesn't it make sense ?

yoshiokatsuneo avatar Jun 25 '15 01:06 yoshiokatsuneo

@yoshiokatsuneo what you should do instead is:

$ yo angular-fullstack:route post
? Where would you like to create this route? client/app/main/
? What will the url of your route be? /post
   create client/app/main/post/post.js
   create client/app/main/post/post.controller.js
   create client/app/main/post/post.controller.spec.js
   create client/app/main/post/post.html
   create client/app/main/post/post.scss

kingcody avatar Jul 25 '15 18:07 kingcody

@kingcody In that case, controller name is not "MainPostCtrl" but just "PostCtrl". So, when I created "main/create", "main/index", or "main/show" controllers, the controller names can easily conflicts with other controller in other directory(ex: "main2/index").

yoshiokatsuneo avatar Jul 27 '15 06:07 yoshiokatsuneo

@yoshiokatsuneo I understand your use case now, thank you. I'm wondering if generating your routes like yo angular-fullstack:route mainCreate or yo angular-fullstack:route mainShow would be an acceptable solution.

kingcody avatar Jul 27 '15 06:07 kingcody

@kingcody Yes, that's the way I do as a workaround, for now. :-) I am a bit afraid of scattering controllers(or filters or directives) on the same directory in the future, and thought nice if i can group some controllers.

yoshiokatsuneo avatar Jul 27 '15 07:07 yoshiokatsuneo

Any thought on how such a grouping feature would work? What would be the logic for determining the path from a complex name such as main/index or main.index so that the path would be client/app/main/index/index.* and angular names would be MainIndex?

kingcody avatar Jul 27 '15 07:07 kingcody

@kingcody How about just using controller basename as filename like "client/app/main/index/mainIndex.controller.js" ? Controller names can be "mainIndexCtrl"(as it is now for "main/index" routing).

yoshiokatsuneo avatar Jul 27 '15 08:07 yoshiokatsuneo