AngularJS support for ReSharper

In case you haven’t already been introduced, AngularJS is a popular JavaScript framework for creating dynamic web applications. It provides many of the services required to build such applications, not the least of which is a declarative approach to updating the UI. It favours the use of data binding and templates over direct DOM manipulation, and it makes it possible to create complex sites with a minimum of code. For more information, check out the examples on their home page, or take a look at the video tutorials by our very own John Lindquist.

We’ve just released a plugin that adds ReSharper support for some of AngularJS’ features (here’s a direct download link). It’s an initial version, so doesn’t cover everything, but what it provides should give you a helping hand in creating your sites. Currently, the plugin provides code-completion for Angular’s custom HTML attributes, and a bundle of Live Templates to make building common constructs easier.

Code completion will include all of AngularJS’ “ng-” attributes when editing HTML files, and include a description tooltip:

Code completion showing Angular attributes

It also supports the HTML5 “data-” prefixed versions of the same attributes.

Code completion with data prefixed attributes

And of course, since ReSharper has smart matching, you can type initials to quickly get to the start of the attribute you want. For example, you can type “dngbh” to get to the “data-ng-bind-html” attribute:

Code completion with smart matching

The plugin also ships with 26 Live Templates, based on the IntelliJ and WebStorm templates by Pawel Kozlowski and John Lindquist, respectively. They are split into functionality for directives, modules, scope, routing, html and global helpers. For example, you can use the “ngindex” template to create a simple HTML page to start your development,  or “ngb” to create a binding expression. These work in HTML or HTML-like files (Razor, ASPX, .html)

Expanding the binding template in a HTML file

The JavaScript templates can create code for directives, for loops, modules, routing and scope. These are available in JavaScript files, and within script tags in HTML-like files:

Expanding a scope function template

Please check out the templates explorer to get a full list, or to edit, add or remove templates.

This is just an initial release. We’d love to expand the feature set, supporting custom HTML element directives, navigation to model properties, binding expressions, and more. If there are any features you’d like to see, or if you find any bugs, please add a feature request to the Issues page. And of course, it’s Open Source – if you’d like to see a new feature, how about taking a crack at it? We’ll help.

Now, go and download it, and make lovely dynamic JavaScript applications.

This entry was posted in News and Events, ReSharper Tips&Tricks and tagged , , , , . Bookmark the permalink.

30 Responses to AngularJS support for ReSharper

  1. Johan says:

    Wooooohooooooooo!

  2. Craig says:

    Now I want the same thing for Knockout…:)

  3. Frank says:

    Thanks, JetBrains for bringing this plugin to public attention! I used an old build of the plugin. I’m sure it will quickly continue to develop in the near future.

    @Craig: Web Essentials 2012 provides Knockout support out of the box, including binding-intellisense!

  4. Mark Rendle says:

    Awesome work!

    Please, can you make the JavaScript Live Templates work in TypeScript files too? AngularJS and TypeScript go together like peanut butter and jam.

  5. Craig says:

    Terrific, thanks Frank, I’ll check that out!

  6. Craig says:

    Terrific, thanks Frank I’ll check that out!

  7. Matt Ellis says:

    @Mark Good idea! I’ll add it to the next release.

    In the meantime, you can edit the templates scope to include *.ts files. When you edit the template, click the link that says “In JS expressions” and in the dialog that appears, check the “in files matching *.*” and expand the arrow. Set the text to *.ts and save the template.

  8. Steve Holmes says:

    How come no ultimate edition support?

  9. Jason Finch says:

    Awesome stuff Jetbrains!

  10. Matt Ellis says:

    Hi Steve. Could you clarify, please? This plugin doesn’t require any particular support for Visual Studio editions.

  11. David Hanson says:

    Guys this is awesome,

    Can you enable template support for TypeScript too? would be awesome!

  12. Matt Ellis says:

    I’ve just pushed a 1.1 update that adds basic support for templates in TypeScript files. They work with tab expansion, but don’t appear in intellisense, as that’s provided by Visual Studio in .ts files.

    https://github.com/JetBrains/resharper-angularjs/wiki/Release-Notes

  13. Kamshare says:

    Hi – I am new to .Net and wanted to learn AngularJS. Can someone help me to add this plugin to Visaul Studio.

    I downloaded this plugin and added a reference to this folder in Tools Menu > Options > Environment > Add-In/Macro Security > Added Path to AngularJS folder. This way I am not able to see the intellisence. I don’t even see this under Addins.

    Please help.

    Thank You.

  14. Matt Ellis says:

    It’s not a Visual Studio addin, so you don’t need to add it with the Visual Studio addin manager. Instead, extract the files in the zip file, and double click the Install-AngularJS.7.1.bat file. This should install the plugin for you.

  15. Zeeshan Abbasi says:

    Great, Just what I was looking for.

  16. daniel says:

    this does not work with the resharper 8 beta

  17. Rusty says:

    I ran the Install-AngularJS.7.1.bat file from the downloaded zip file, however my visual studio 2012 does not show any angularjs intellisense. I’m using Visual Studio 2012 Ultimate with ReSharper 7.0

  18. Matt Ellis says:

    @daniel – you can use ReSharper 8′s extension manager (in the ReSharper menu) to download a version of the plugin for ReSharper 8.

    @Rusty – the plugin doesn’t work with 7.0, only 7.1. This is because 7.1 is a free upgrade to 7.0 – just download it from the website.

  19. Dov says:

    Can you please explain in more details, how to install it for Resharper 8?
    I just downloaded Beta 8, and I don’t know exactly what to do in the Extension Manager.
    Thanks

  20. Matt Ellis says:

    It’s very straight-forward. Simply go to the ReSharper menu, select “Extension Manager” and then it’s just like the normal NuGet interface. Select “Online” from the list on the left, and type “Angular” in the search box in the top right. You should now see the AngularJS extension listed. Click it, and click the install button. And that’s it!

  21. Dov says:

    Thanks, I just installed it.
    You should add to the steps above that before searching for “Angular”, the user should select from the upper left drop-down, “Include Prerelease”.

  22. Lanier says:

    Do you know how to fix this?

    <div class="bar" style="width:{{Progress}}%;"></div>

    Resharper think that this is a critical error saying:
    Property Progress doesn’t exist in css 3.0

    In fact, if there were any way to say ingore errors that contain {{}} that would probably fix most of the false warning/errors resharper is showing me for angular.

  23. Tomer says:

    How do I get rid of the red marker on Angular’s directives (or mine)?

  24. Matt Ellis says:

    @Lanier, @Tomer – unfortunately, the plugin doesn’t recognise this syntax, and so they get treated as errors. Also, Visual Studio’s syntax highlighting gets involved and complains that Angular’s directives aren’t valid HTML.

  25. Sam Blowes says:

    Are there any plans to allow angular tags.
    Like ng-form ?

    It currently shows a warning when using tags like this are in your page.

  26. Sam Blowes says:

    @Lanier you should be using the ngStyle attribute
    http://docs.angularjs.org/api/ng.directive:ngStyle

  27. Bruce Wayne says:

    Needs an update for the latest resharper! Jetbrains should have a vested interest in maintaining this …

  28. Bruce Wayne says:

    Apologies, it is updated – I should learn to read ;) get it via the resharper -> extension manager

  29. Tacker says:

    I ran the .bat file but still don’t see the intellisense. Am I missing an additional step?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">