feat(dart/transform) Register parameter metadata information
Adds any metadata attached to a parameter to the "parameters" value passed in to `registerType`. For example: `MyComponent(@Inject(Foo) foo)` generates `"parameters": const [const [const Inject(Foo)]]` Also reorganizes the testing code. Closes #7
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
library bar;
|
||||
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
@Component(selector: 'soup', componentServices: const [ToolTip])
|
||||
class MyComponent {}
|
||||
|
||||
@Decorator(selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
|
||||
class ToolTip {
|
||||
String text;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
library bar;
|
||||
|
||||
import 'bar.dart';
|
||||
import 'package:angular2/src/core/annotations/annotations.dart';
|
||||
|
||||
bool _visited = false;
|
||||
void setupReflection(reflector) {
|
||||
if (_visited) return;
|
||||
_visited = true;
|
||||
reflector
|
||||
..registerType(MyComponent, {
|
||||
"factory": () => new MyComponent(),
|
||||
"parameters": const [],
|
||||
"annotations": const [
|
||||
const Component(selector: 'soup', componentServices: const [ToolTip])
|
||||
]
|
||||
})
|
||||
..registerType(ToolTip, {
|
||||
"factory": () => new ToolTip(),
|
||||
"parameters": const [],
|
||||
"annotations": const [
|
||||
const Decorator(
|
||||
selector: '[tool-tip]', bind: const {'text': 'tool-tip'})
|
||||
]
|
||||
})
|
||||
..registerSetters({"text": (ToolTip o, String value) => o.text = value});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
library web_foo;
|
||||
|
||||
import 'package:angular2/src/core/application.dart';
|
||||
import 'package:angular2/src/reflection/reflection_capabilities.dart';
|
||||
import 'bar.dart';
|
||||
|
||||
void main() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
bootstrap(MyComponent);
|
||||
}
|
||||
Reference in New Issue
Block a user