1 @Output() open: EventEmitter<any> = new EventEmitter();
2
3
4 toggel() {
5 this.open.emit(null);
6 }
1
2 content_copy
3
4 @Component({
5 selector: 'zippy',
6 template: `
7 <div class="zippy">
8 <div (click)="toggle()">Toggle</div>
9 <div [hidden]="!visible">
10 <ng-content></ng-content>
11 </div>
12 </div>`})
13export class Zippy {
14 visible: boolean = true;
15 @Output() open: EventEmitter<any> = new EventEmitter();
16 @Output() close: EventEmitter<any> = new EventEmitter();
17
18 toggle() {
19 this.visible = !this.visible;
20 if (this.visible) {
21 this.open.emit(null);
22 } else {
23 this.close.emit(null);
24 }
25 }
26}
27
1
2 class EventEmitter<T> extends Subject {
3 constructor(isAsync?: boolean): EventEmitter<T>
4 emit(value?: T): void
5 subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription
6}
7