javascript - AngularJS: can I use filter, defined in another module? -
i've angular project, structured using by-module-type principle:
├── directives ├── services ├── filters │ └── filters.js └── states └── home ├── home.html └── home.module.js
i've created custom filter in filters.js
import angular "angular"; export default angular.module("app.filters", []) .filter("removestartingwithdollar", function(items) { var filtereditems = []; angular.foreach(items, function(item) { if (!item.startswith('$')) { filtereditems.push(item); } }); return filtereditems; });
i want use removestartingwithdollar
filter in home.html template. how inject dependency , should @ all?
just inject app.filters
module in anywhere need use provider of it.
angular.module("mysecondmodule", [app.filters])
Comments
Post a Comment