@@ -27,10 +27,10 @@ class TemplateElementBinder extends ElementBinder {
27
27
_registerViewFactory (node, parentInjector, nodeModule) {
28
28
assert (templateViewFactory != null );
29
29
nodeModule
30
- ..bind ( ViewPort , toFactory: (_) =>
31
- new ViewPort (node, parentInjector.get ( Animate )))
32
- ..bind ( ViewFactory , toValue: templateViewFactory)
33
- ..bind ( BoundViewFactory , toFactory: (Injector injector) =>
30
+ ..bindByKey ( _VIEW_PORT_KEY , toFactory: (_) =>
31
+ new ViewPort (node, parentInjector.getByKey ( _ANIMATE_KEY )))
32
+ ..bindByKey ( _VIEW_FACTORY_KEY , toValue: templateViewFactory)
33
+ ..bindByKey ( _BOUND_VIEW_FACTORY_KEY , toFactory: (Injector injector) =>
34
34
templateViewFactory.bind (injector));
35
35
}
36
36
}
@@ -203,7 +203,7 @@ class ElementBinder {
203
203
204
204
void _link (nodeInjector, probe, scope, nodeAttrs, formatters) {
205
205
_usableDirectiveRefs.forEach ((DirectiveRef ref) {
206
- var directive = nodeInjector.get (ref.type );
206
+ var directive = nodeInjector.getByKey (ref.typeKey );
207
207
probe.directives.add (directive);
208
208
209
209
if (ref.annotation is Controller ) {
@@ -240,18 +240,18 @@ class ElementBinder {
240
240
void _createDirectiveFactories (DirectiveRef ref, nodeModule, node, nodesAttrsDirectives, nodeAttrs,
241
241
visibility) {
242
242
if (ref.type == TextMustache ) {
243
- nodeModule.bind ( TextMustache , toFactory: (Injector injector) {
244
- return new TextMustache (node, ref.value, injector.get ( Interpolate ),
245
- injector.get ( Scope ), injector.get ( FormatterMap ));
243
+ nodeModule.bindByKey ( _TEXT_MUSTACHE_KEY , toFactory: (Injector injector) {
244
+ return new TextMustache (node, ref.value, injector.getByKey ( _INTERPOLATE_KEY ),
245
+ injector.getByKey ( _SCOPE_KEY ), injector.getByKey ( _FORMATTER_MAP_KEY ));
246
246
});
247
247
} else if (ref.type == AttrMustache ) {
248
248
if (nodesAttrsDirectives.isEmpty) {
249
249
nodeModule.bind (AttrMustache , toFactory: (Injector injector) {
250
- var scope = injector.get ( Scope );
251
- var interpolate = injector.get ( Interpolate );
250
+ var scope = injector.getByKey ( _SCOPE_KEY );
251
+ var interpolate = injector.getByKey ( _INTERPOLATE_KEY );
252
252
for (var ref in nodesAttrsDirectives) {
253
253
new AttrMustache (nodeAttrs, ref.value, interpolate, scope,
254
- injector.get ( FormatterMap ));
254
+ injector.getByKey ( _FORMATTER_MAP_KEY ));
255
255
}
256
256
});
257
257
}
@@ -266,23 +266,24 @@ class ElementBinder {
266
266
} else {
267
267
factory = _componentFactory;
268
268
}
269
- nodeModule.bind (ref.type , toFactory: factory .call (node, ref), visibility: visibility);
269
+ nodeModule.bindByKey (ref.typeKey , toFactory: factory .call (node, ref), visibility: visibility);
270
270
} else {
271
- nodeModule.bind (ref.type , visibility: visibility);
271
+ nodeModule.bindByKey (ref.typeKey , visibility: visibility);
272
272
}
273
273
}
274
274
275
275
// Overridden in TemplateElementBinder
276
276
void _registerViewFactory (node, parentInjector, nodeModule) {
277
- nodeModule..bind ( ViewPort , toValue: null )
278
- ..bind ( ViewFactory , toValue: null )
279
- ..bind ( BoundViewFactory , toValue: null );
277
+ nodeModule..bindByKey ( _VIEW_PORT_KEY , toValue: null )
278
+ ..bindByKey ( _VIEW_FACTORY_KEY , toValue: null )
279
+ ..bindByKey ( _BOUND_VIEW_FACTORY_KEY , toValue: null );
280
280
}
281
281
282
+
282
283
Injector bind (View view, Injector parentInjector, dom.Node node) {
283
284
Injector nodeInjector;
284
- Scope scope = parentInjector.get ( Scope );
285
- FormatterMap formatters = parentInjector.get ( FormatterMap );
285
+ Scope scope = parentInjector.getByKey ( _SCOPE_KEY );
286
+ FormatterMap formatters = parentInjector.getByKey ( _FORMATTER_MAP_KEY );
286
287
var nodeAttrs = node is dom.Element ? new NodeAttrs (node) : null ;
287
288
ElementProbe probe;
288
289
@@ -291,12 +292,12 @@ class ElementBinder {
291
292
292
293
var nodesAttrsDirectives = [];
293
294
var nodeModule = new Module ()
294
- ..bind ( NgElement )
295
- ..bind ( View , toValue: view)
296
- ..bind (dom. Element , toValue: node)
297
- ..bind (dom. Node , toValue: node)
298
- ..bind ( NodeAttrs , toValue: nodeAttrs)
299
- ..bind ( ElementProbe , toFactory: (_) => probe);
295
+ ..bindByKey ( _NG_ELEMENT_KEY )
296
+ ..bindByKey ( _VIEW_KEY , toValue: view)
297
+ ..bindByKey ( _ELEMENT_KEY , toValue: node)
298
+ ..bindByKey ( _NODE_KEY , toValue: node)
299
+ ..bindByKey ( _NODE_ATTRS_KEY , toValue: nodeAttrs)
300
+ ..bindByKey ( _ELEMENT_PROBE_KEY , toFactory: (_) => probe);
300
301
301
302
directiveRefs.forEach ((DirectiveRef ref) {
302
303
Directive annotation = ref.annotation;
@@ -317,7 +318,7 @@ class ElementBinder {
317
318
318
319
nodeInjector = parentInjector.createChild ([nodeModule]);
319
320
probe = _expando[node] = new ElementProbe (
320
- parentInjector.get ( ElementProbe ), node, nodeInjector, scope);
321
+ parentInjector.getByKey ( _ELEMENT_PROBE_KEY ), node, nodeInjector, scope);
321
322
322
323
_link (nodeInjector, probe, scope, nodeAttrs, formatters);
323
324
0 commit comments