Perhaps...
In the example you gave, the functions sample* are injected into the class
constructor. This means that the creator of *new Test* needs to know all
the things that need to be injected. This can be handled by creating a sort
of PipeRegistrationService, which would be in charge of maintaining a list
of PipeTransform injectables and creating a new instance of the MetaFilter
(in this case *Test*) class. This is a valid solution, but it unfortunately
doesn't make use of Angular 2.0's injection mechanism or @Pipe annotation.
This means all producers of these pipes have to register them with
angular's @Pipe and also add themselves to my PipeRegistrationService.
Ideally, the *Test* class above could look at Angular's already registered
PipeTransforms and just use those, without having to explicitly inject them
all.
On Thursday, May 5, 2016 at 11:53:25 PM UTC-7, Sander Elias wrote:
>
> Hi Aaron,
>
> When you have injected all the pipes available into an controller, and
> assigned all of them to 'this', you can.
>
> have a look at this:
>
> class test {
> constructor(...injectables) {
> injectables.forEach((injectable) => this[injectable.name]=
> injectable)
> }
> read(name) {
> return this[name];
> }
> }
>
> function sample1() { return "I'm sample1"}
> function sample2() { return "I'm sample2"}
> function sample3() { return "I'm sample3"}
>
> let something = new test(sample1, sample2, sample3) //simulating injection
>
> let result = something.read('sample1')
> result()
> something.read('sample3')();
>
> Is this enough for you to implement this?
>
> Regards
> Sander
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.