Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs的PHPStorm/WebStorm中的代码高亮显示_Angularjs_Phpstorm_Webstorm - Fatal编程技术网

Angularjs的PHPStorm/WebStorm中的代码高亮显示

Angularjs的PHPStorm/WebStorm中的代码高亮显示,angularjs,phpstorm,webstorm,Angularjs,Phpstorm,Webstorm,在我的控制器中,我有一个函数定义为: var ProductListingHeaderController = function (FilterService, CategoryService) { this.isCategorySet = function () { return (FilterService.categoryID); }; this.categoryName = function () { return (Categor

在我的控制器中,我有一个函数定义为:

var ProductListingHeaderController = function (FilterService, CategoryService) {
    this.isCategorySet = function () {
        return (FilterService.categoryID);
    };
    this.categoryName = function () {
        return (CategoryService.categoryName());
    };
};
IDE通过代码高亮显示将categoryName报告为正在使用,而将CategorySet报告为未使用

这是可以理解的,因为:

categoryName在html文件的{{}内使用:

<h2>{{productListingHeader.categoryName()}}</h2>
考虑到这是一种常见的用法,我怀疑我可能在Storm中缺少了一个设置,即如何设置东西,以便Angle指令在字符串中的这种用法在使用时得到识别


提前感谢您的反馈。

这是PHP/WebStorm的正常行为

模板->JavaScript实际上只是一个模棱两可的连接。AngularJS模板中不支持jsDoc类型推断。因此,只要函数名是唯一的,PHP/WebStorm将匹配JavaScript的模板函数调用

PHP/WebStorm在将闭包方法推断为对象函数时存在问题。我在使用AngularJS控制器的原型声明时取得了更好的成功

var ProductListingHeaderController = function (FilterService, CategoryService) {
    this.filterService = FilterService;
    this.categoryService = CategoryService;
}
ProductListingHeaderController.prototype.isCategorySet = function () {
    return (this.filterService.categoryID);
};
ProductListingHeaderController.prototype.categoryName = function () {
    return (this.categoryService.categoryName());
};
将上面的代码与您的代码进行比较,并查看WebStorm中的explore结构。当您为控制器使用原型时,它们会正确地显示在资源管理器中

var ProductListingHeaderController = function (FilterService, CategoryService) {
    this.filterService = FilterService;
    this.categoryService = CategoryService;
}
ProductListingHeaderController.prototype.isCategorySet = function () {
    return (this.filterService.categoryID);
};
ProductListingHeaderController.prototype.categoryName = function () {
    return (this.categoryService.categoryName());
};