On Wednesday, May 4, 2016 at 11:11:14 PM UTC+2, JM wrote:
>
>
> Is there a chance to include the creation of secondsChange with the
> @Output decorator from inside the @InAndOut decorator.
> So I could reduce the lines:
>
>
> @InAndOut public seconds:number = 0;
> @Output("secondsChange") secondsChange = new EventEmitter();
>
>
>
> to:
>
>
> @InAndOut public seconds:number = 0;
>
>
>
>
>
Hi Jan,
Without actually trying anything, I would say that your @InAndOut type
should not be a number, but rather an event emitter if you want it to emit
values (e.g. *@InAndOut public seconds:EventEmitter<number> = new
EventEmitter();*). But then we lost the @In part, so it proabbly would not
merge the two lines into one.
With a disclaimer on lack of my expertise here, I would say if you want
something to be shared among multiple components in NG2, that it goes into
its own component/service. So, if somebody besides the "Clock" here wanted
to know about "Timer.seconds", they'd have to listen to timer directly. But
then you can't wrap that whole functionality around the "Clock" nicely, so
that external components don't need to know, so we're back at square 1. An
interesting problem.
In any case, the @InAndOut looks like a great deal of help there with this
kind of work.
--
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.