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?
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)
}
}
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