feat(transformer): Support @Injectable() on static functions

This commit is contained in:
Jacob MacDonald
2015-06-30 08:39:03 -07:00
parent 311b47720b
commit 7986e7ce7e
5 changed files with 75 additions and 13 deletions
@@ -93,6 +93,9 @@ void allTests() {
'ERROR: Could not read asset at uri bad_relative_url.css from angular2|'
'test/transform/directive_processor/invalid_url_files/hello.dart'
]);
_testNgDeps('should find and register static functions.',
'static_function_files/hello.dart');
}
void _testNgDeps(String name, String inputPath,
@@ -0,0 +1,20 @@
library static_function_files.hello.ng_deps.dart;
import 'hello.dart';
import 'package:angular2/angular2.dart';
var _visited = false;
void initReflector(reflector) {
if (_visited) return;
_visited = true;
reflector
..registerFunction(getMessage, {
'parameters': const [const [const Inject(Message)]],
'annotations': const Injectable()
})
..registerType(Message, {
'factory': () => new Message(),
'parameters': const [],
'annotations': const [const Injectable()]
});
}
@@ -0,0 +1,11 @@
library static_function_files.hello;
import 'package:angular2/angular2.dart';
@Injectable()
String getMessage(@Inject(Message) message) => message.value;
@Injectable()
class Message {
String value = 'hello!';
}