Skip to content

Instantly share code, notes, and snippets.

@douglasduteil
Created February 12, 2016 18:33
Show Gist options
  • Save douglasduteil/8c5504797f4a6b31f1f5 to your computer and use it in GitHub Desktop.
Save douglasduteil/8c5504797f4a6b31f1f5 to your computer and use it in GitHub Desktop.
Shows how to write a zippy component in pure ES6
// following https://github.com/angular/angular/blob/2.0.0-beta.6/modules/playground/src/zippy_component/zippy.ts
import {Component, EventEmitter, Input, Output} from 'angular2/core';
import {ObservableWrapper} from 'angular2/src/facade/async';
export Zippy;
Zippy.annotations = [
new Component({
selector: 'zippy',
templateUrl: 'zippy.html'
})
];
Reflect.decorate([Input()], Zippy.prototype, 'title', '');
Reflect.decorate([Output()], Zippy.prototype, 'open', new EventEmitter());
Reflect.decorate([Output()], Zippy.prototype, 'close', new EventEmitter());
function Zippy () {
this.visible = true;
this.toggle = toggle;
//
function toggle() {
this.visible = !this.visible;
if (this.visible) {
ObservableWrapper.callEmit(this.open, null);
} else {
ObservableWrapper.callEmit(this.close, null);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment