refactor(playground): update Zippy to use @Input and @Output
This commit is contained in:
parent
bf07f9c3e1
commit
134c6f57d5
|
@ -1,21 +1,19 @@
|
||||||
import {Component, View, EventEmitter} from 'angular2/angular2';
|
import {Component, View, EventEmitter, Input, Output} from 'angular2/angular2';
|
||||||
import {ObservableWrapper} from 'angular2/src/core/facade/async';
|
import {ObservableWrapper} from 'angular2/src/core/facade/async';
|
||||||
|
|
||||||
@Component(
|
@Component({selector: 'zippy', templateUrl: 'zippy.html'})
|
||||||
{selector: 'zippy', inputs: ['title'], outputs: ['openHandler: open', 'closeHandler: close']})
|
|
||||||
@View({templateUrl: 'zippy.html'})
|
|
||||||
export class Zippy {
|
export class Zippy {
|
||||||
visible: boolean = true;
|
visible: boolean = true;
|
||||||
title: string = '';
|
@Input() title: string = '';
|
||||||
openHandler: EventEmitter<any> = new EventEmitter();
|
@Output() open: EventEmitter<any> = new EventEmitter();
|
||||||
closeHandler: EventEmitter<any> = new EventEmitter();
|
@Output() close: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
this.visible = !this.visible;
|
this.visible = !this.visible;
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
ObservableWrapper.callNext(this.openHandler, null);
|
ObservableWrapper.callNext(this.open, null);
|
||||||
} else {
|
} else {
|
||||||
ObservableWrapper.callNext(this.closeHandler, null);
|
ObservableWrapper.callNext(this.close, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue