3

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 1

3

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)
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.