Created
February 12, 2016 18:33
-
-
Save douglasduteil/8c5504797f4a6b31f1f5 to your computer and use it in GitHub Desktop.
Shows how to write a zippy component in pure ES6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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