0
votes

Is there a way for WebStorm to "see" the methods in my HTML and link them with their respective component class?

Details

I usually write my component controller in one file and the component template (html) in another file.

When I do this, methods that are only used in the template are marked as "unused" by WebStorm, and they throw a warning.

For example, in the component ctrl I have a handleViewChange() method.

In the template file I have vm.handleViewChange();

WebStorm warns me that handleViewChange is an unused method even though I have used it in the template.


Please note: I am aware that I can suppress the warn for this particular statement. I would rather WebStorm recognized the method is actually used.

Particularly relevant with refactor-happy colleagues (or refactor-happy future me).


Edit #1

I have already enabled the AngularJS library in Webstorm settings, but it does not fix this particular issues.

enter image description here

1
did you check this ?Neji Soltani
@SoltaniNeji Yes I have, but thanks for asking!user2954463
do you have AngularJS support enabled? Are the built-in directives (ng-app, ng-controller, etc) recognized? Can you jump to method definitions from your template files? If Angular support is off - see my answer for instructions on enabling it. If it's on, and methods are still marked unused, etc, please provide code snippets that show methods definition and usageslena

1 Answers

0
votes

Downloading angular TypeScript community stubs per suggestion at this post doesn't enable AngularJS support for your project. You need to have angular.js file (debug version, uncompressed!) in your project (either in your project directory or configured as JavaScript library) - normally it's enough to get Angular directives/methods recognized. See http://blog.jetbrains.com/webstorm/2014/03/angularjs-workflow-in-webstorm/, 'Include angular.js in Your Project' section.