resharper-angularjs icon indicating copy to clipboard operation
resharper-angularjs copied to clipboard

option to create/navigate to a controller from ng-controller

Open kkozmic opened this issue 11 years ago • 11 comments

Those are effectively two features, so I'm happy to split it into two requests:

One is to be able to write ng-controller="FooController" or ng-controller="FooController as vm" and have an option to alt + Enter to create a new controller with this name.

Second one would be to navigate to definition when the controller exists.

kkozmic avatar Jan 11 '14 04:01 kkozmic

This is similar to PR #11, which would add a reference between the value of the ng-controller attribute and the controller function in JavaScript. Adding a reference enables the ctrl+click navigation, (mostly) code completion when editing, and partaking in renaming. @DerAlbertCom has done some work on this already - Albert, it would be great if you could do a new PR with your changes, even if they're unfinished.

The second part, create from usage, isn't covered and will have to be a separate piece of work. How would you expect it to work - where would it create the controller? In the HTML file, or in a new file, alongside, or in the scripts folder?

citizenmatt avatar Jan 20 '14 11:01 citizenmatt

re: 2nd part

I realise that's not everybody's preference, but the way I structure the code is having them side by side:

/shoppingCart/
    shoppingCart.html
    shoppingCartController.js

That would obviously be my preference.

kkozmic avatar Jan 20 '14 12:01 kkozmic

Is there a convention in angularjs world (I'm not familiar enough)?

citizenmatt avatar Jan 20 '14 12:01 citizenmatt

I'm not sure,,, haven't seen any strong guidance around that, but I'm quite new to Angular myself, and figuring it out as I go

kkozmic avatar Jan 20 '14 12:01 kkozmic

No it is not a convention. most from what i see put the view in seperate folders

DerAlbertCom avatar Jan 21 '14 18:01 DerAlbertCom

@citizenmatt i think on the weekend i can work in the plugin

DerAlbertCom avatar Jan 21 '14 18:01 DerAlbertCom

btw. the "other" guys uses often yeoman

For an example of the structure look here.

http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/

DerAlbertCom avatar Jan 21 '14 18:01 DerAlbertCom

Hi @DerAlbertCom - any movement on the PR? I'm going to need an ICache implementation soon. I'm happy if you just want to push what you've got.

citizenmatt avatar Feb 10 '14 08:02 citizenmatt

@citizenmatt my last work is on https://github.com/deralbertcom/resharper-angularjs

Some initial Cache implementation

https://github.com/DerAlbertCom/resharper-angularjs/tree/master/src/resharper-angularjs/JavaScript

and support for a solution specific xml with "own" directives.

https://github.com/DerAlbertCom/resharper-angularjs/blob/master/src/resharper-angularjs/Html/SolutionDeclaredElementsProvider.cs

DerAlbertCom avatar Feb 10 '14 16:02 DerAlbertCom

@DerAlbertCom, are you ok if I cherry pick some of those commits? I want to get back onto this, but the project's changed a lot since the branch started, so I think it might be easier to pull in the most relevant commits and work from there. How does that sound?

citizenmatt avatar May 05 '14 13:05 citizenmatt

Pick it.

DerAlbertCom avatar May 06 '14 13:05 DerAlbertCom