Skip to content

Instantly share code, notes, and snippets.

@shuhei
Last active August 29, 2015 14:17
Show Gist options
  • Save shuhei/6e0b91b6a021c19541a1 to your computer and use it in GitHub Desktop.
Save shuhei/6e0b91b6a021c19541a1 to your computer and use it in GitHub Desktop.
Angular 2 annotation with babel (babel --experimental with experimental branch)
import {Component as _Component, Template as _Template} from 'angular2/src/core/annotations/annotations';
function makeDecorator(annotationClass) {
return (options) => {
return (klass) => {
klass.annotations = klass.annotations || [];
klass.annotations.push(new annotationClass(options));
return klass;
};
};
}
const Component = makeDecorator(_Component);
const Template = makeDecorator(_Template);
@Component({
selector: 'hello'
})
@Template({
inline: '<p>Hello, World!</p>'
})
class HelloComponent {
}
"use strict";
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _angular2SrcCoreAnnotationsAnnotations = require("angular2/src/core/annotations/annotations");
var _Component = _angular2SrcCoreAnnotationsAnnotations.Component;
var _Template = _angular2SrcCoreAnnotationsAnnotations.Template;
function makeDecorator(annotationClass) {
return function (options) {
return function (klass) {
klass.annotations = klass.annotations || [];
klass.annotations.push(new annotationClass(options));
return klass;
};
};
}
var Component = makeDecorator(_Component);
var Template = makeDecorator(_Template);
var HelloComponent = (function () {
function HelloComponent() {
_classCallCheck(this, HelloComponent);
}
HelloComponent = Component({
selector: "hello"
})(HelloComponent) || HelloComponent;
HelloComponent = Template({
inline: "<p>Hello, World!</p>"
})(HelloComponent) || HelloComponent;
return HelloComponent;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment