Skip to content

Instantly share code, notes, and snippets.

@kasperpeulen
Last active August 29, 2015 14:24
Show Gist options
  • Save kasperpeulen/5a0e89c90c8a732aa744 to your computer and use it in GitHub Desktop.
Save kasperpeulen/5a0e89c90c8a732aa744 to your computer and use it in GitHub Desktop.
A basic example showing how to use the @component annotation in angular2.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<my-app></my-app>
<script type="application/dart" src="main.dart"></script>
</body>
</html>
import 'package:angular2/angular2.dart';
import 'package:angular2/src/reflection/reflection.dart' show reflector;
import 'package:angular2/src/reflection/reflection_capabilities.dart' show ReflectionCapabilities;
@Component(selector: 'child')
@View(template: '''
<p> {{ message }} </p>
''')
class ChildComponent {
String message = "I'm the child";
}
@Component(selector: 'my-app')
@View(template: '''
<h1>{{ message }}</h1>
<child></child>
''', directives: const [ChildComponent])
class MyApp {
String message = "I'm the parent";
}
main() {
reflector.reflectionCapabilities = new ReflectionCapabilities();
bootstrap(MyApp);
}
name: angular2.angular2_Component
description: >
A basic example showing how to use the @Component annotation in angular2.
homepage:
homepage: https://gist.github.com/kasperpeulen/5a0e89c90c8a732aa744
environment:
sdk: '>=1.0.0 <2.0.0'
dependencies:
angular2: 2.0.0-alpha.29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment