Skip to content

Instantly share code, notes, and snippets.

@alexeagle
Created April 20, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexeagle/24243fbb87dbd8bad6f1 to your computer and use it in GitHub Desktop.
Save alexeagle/24243fbb87dbd8bad6f1 to your computer and use it in GitHub Desktop.
cd TypeScript
git reset --hard 62b15de666fbce283b97f1f99c2f799d04a8e0b5 # HEAD from master
npm install reflect-metadata
rm -rf built && jake
node built/local/tsc.js test.ts -t es6 --emitDecoratorMetadata
npm install -g babel
babel test.js > app_bin.js
# load test.html in browser
<!doctype html>
<html>
<head>
<script src="node_modules/reflect-metadata/Reflect.js"/>
<script src="//code.angularjs.org/2.0.0-alpha.19/angular2.sfx.dev.js"></script>
</head>
<body>
<todo-app>
Loading...
</todo-app>
<script src="app_bin.js"></script>
</body>
</html>
var angular = window.angular;
class Service {
greeting() {
return 'Hello';
}
}
@angular.Component({
selector: 'app',
injectables: [Service]
})
@angular.View({
template: '{{greeting}} world!'
})
class App {
private greeting;
static parameters;
constructor(service: Service) {
this.greeting = service.greeting();
setTimeout(() => this.greeting = 'Howdy,', 1000);
}
}
App.parameters = window.Reflect.getMetadata('design:paramtypes', App).map((p) => [p]);
angular.bootstrap(App);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment