feat(transformer): Support @Injectable() on static functions
This commit is contained in:
@@ -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,
|
||||
|
||||
+20
@@ -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!';
|
||||
}
|
||||
Reference in New Issue
Block a user