How can I utilize angular $filter within a custom filter? How to inject $filter dependency?
module Filters {
export class CustomFilter {
public static Factory() {
return function (input:<any>) {
var result = [];
//Would like to utilize $filter.('filter') here
return result;
}
}
}
angular.module('app')
.filter('customFilter', [CustomFilter.Factory]);
}
You could just inject $filter
and use type ng.IFilterService
or specifically use filterFilter
(if you are looking for $filter('filter')
) and use type Function
.
module Filters {
export class CustomFilter {
//Here use `$filter` or filterFilter itself
//public static Factory($filter: ng.IFilterService)
public static Factory(filter:Function) {
return function (input:any) {
var result = [];
//filter is now $filter('filter')
return result;
}
}
}
angular.module('app')
.filter('customFilter', ['filterFilter', CustomFilter.Factory]);
//Inject $filter for generic filter getter
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With