AngularJS ES6 语法中过滤器的未知提供程序错误

Unknown provider error for filter in AngularJS ES6 syntax

捆绑并部署到远程服务器后,我无法在我的应用程序中使用过滤器。它在本地运行良好,但如果我远程 运行 我的应用程序,我会收到错误消息:

"Error: [$injector:unpr] Unknown provider: eProvider <- e <- filterByQueryFilter"

这是我的代码:

app.js:

import myFilters from "./shared/filters";
import myModule from "./myModule";

export default angular.module('app', [
    lots-of-modules...,
    myFilters,])
    .config(defaultRouting)
    .run(["$http", "$rootScope", "$state", function($http, $rootScope, $state){ //code.. }]);

index.js(在 shared/filters 文件夹中):

import filterByQuery from "./filterbyquery.filter.js";
import highlightQuery from "./highlightquery.js";
import dateFormatter from "../formatter/dateFormatter";

export default angular.module("my.filters", [])
    .filter("filterByQuery", filterByQuery)
    .filter("highlightQuery", highlightQuery)
    .filter("dateFormatter", dateFormatter)
    .name;

另一个-module.js(我尝试使用过滤器的地方):

export default class anotherModule{

    constructor() {
        this.restrict = 'E';
        this.replace = false;
        this.template = require('./template.html');

        this.scope = {};

        this.controller = AnotherModule;
        this.controllerAs = 'ctrl';
    }
}

class AnotherModule{
    constructor($scope, $filter) {
        this.$filter = $filter;
    }
}

AnotherModule.$inject = [..., "$filter"];

在控制器中使用过滤器:

res = this.$filter("filterByQuery")(res, this.filterString);

考虑到它在本地运行良好,我不太确定我做错了什么。此外,highlightQuery 过滤器通过使用 template.html

中的管道语法来工作

有人知道这里发生了什么吗?

缩小 AngularJS 应用程序应该 properly annotated 以便执行依赖项注入。

filterByQuery 过滤器工厂函数未注释。由于它包含在单独的文件中,因此使用 $inject 注释以便将其与函数本身保持在同一模块中是有意义的。它是 ES6 中带有 ES 模块的注释的首选方式,由 John Papa style guide

提出