angular-styleguide icon indicating copy to clipboard operation
angular-styleguide copied to clipboard

Webstorm's "unresolve function or method" using this styleguide

Open admons opened this issue 8 years ago • 5 comments

Hi,

When using the following code, the "getLang" function isn't recognized by WebStorm 11.0 angular.module('app').controller('languageCtrl', languageCtrl); languageCtrl.$inject = []; function languageCtrl() { var vm = this; vm.getLang = getLang; function getLang() {} } When changing the function name to something else than the controller name (e.g. languageController), the controller method are recognized.

Any idea how to fix this?

admons avatar Feb 07 '16 07:02 admons

What do you mean exactly?

In my case on 11.0.3 work without problem:

angular.module('app').controller('languageCtrl', languageCtrl2);

languageCtrl2.$inject = [];

function languageCtrl2() {
        var vm = this;
        vm.getLang = getLang;
        function getLang() {
        }
}

WuglyakBolgoink avatar Feb 12 '16 13:02 WuglyakBolgoink

Yes, because you're using "languageCtrl2", that's exactly my problem. If you'll use "languageCtrl" it won't work

admons avatar Feb 14 '16 07:02 admons

@admon-s-waklme : Sorry, but I don't understand your problem.

If I use "languageCtrl"-controller instead of "languageCtrl2", it work on me without problem too.

bildschirmfoto 2016-02-14 um 09 05 43

WuglyakBolgoink avatar Feb 14 '16 08:02 WuglyakBolgoink

The function should be added to the body of the activate function. You can always rename activate to getLang but you still need to call/invoke the function, i.e. (). If it still does not work you may want to check your routing.

(function () {
    'use strict';

    angular
        .module('app')
        .controller('languageCtrl', languageCtrl);

    languageCtrl.$inject = [''];

    /* @ngInject */
    function languageCtrl() {
        var vm = this;
        vm.title = 'languageCtrl';

        activate(); // or getLang();

        ////////////////

        function activate() { // or function getLang() {

        }
    }

})();

MelissaMMDP avatar Mar 15 '16 17:03 MelissaMMDP

is this still an issue?

johnpapa avatar Sep 05 '16 18:09 johnpapa