I am using angular's upgrade module to create a hybrid app where both angular js and angular2 can co-exist together.I have a situation here where i need a existing custom filter to be used for a component.Does the upgrade module support upgrading custom filters.Ifsd so please advice how to do that?
1 Answer
Unfortunately upgrade module doesn't support upgrading filters to Pipes. But Pipes are very similar to filters and are really easy to upgrade manually.
If you need to have co-existing filter & Pipe I suggest to extract all logic & transforms to simple TypeScript / JavaScript:
export class PipeUtils {
static myFilterTransform(value, ...args) {
// return transformed value
}
}
AngularJS filter:
angular.module('app', [])
.filter('myFilter', () => PipeUtils.myFilterTransform)
Angular Pipe:
export class MyPipe {
transform(value, ...args) {
return PipeUtils.myFilterTransform(value, ...args)
}
}