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