What is the best practice for routing input/output properties of a subcomponent
including the event logic in angular 2?
The following solution is the only way I found so far.
@Component({
>
> selector: "clock",
> template: `
> <timer [(seconds)]="seconds" [(minutes)]="minutes"></timer>
>
> `
> })
> export class Clock{
>
>
> _seconds:number = 0;
> @Input("seconds")
> set seconds(v:number) {
> this._seconds = v;
> this.secondsChange.emit(v);
> }
> get seconds() {
> return this._seconds ;
> }
> @Output("secondsChange") secondsChange:EventEmitter<number> = new
> EventEmitter();
>
>
> _minutes:number = 0;
> @Input("minutes")
> set minutes(v:number) {
> this._minutes= v;
> this.minutesChange.emit(v);
> }
> get minutes() {
> return this._minutes;
> }
> @Output("minutesChange") minutesChange:EventEmitter<number> = new
> EventEmitter();
>
>
> }
>
>
Now I can detect Changes of the subcomponent <timer> and can pass the event
to the component <clock>.
But, it looks wrong. Especially if you use a lot of properties.
Is there a shorter or recommended way?
Best
Jan
--
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.