| OLD | NEW |
| 1 part of angular.mock; | 1 part of angular.mock; |
| 2 | 2 |
| 3 /* | 3 /* |
| 4 * Use Probe directive to capture the Scope, Injector and Element from any DOM | 4 * Use Probe directive to capture the Scope, Injector and Element from any DOM |
| 5 * location into root-scope. This is useful for testing to get a hold of | 5 * location into root-scope. This is useful for testing to get a hold of |
| 6 * any directive. | 6 * any directive. |
| 7 * | 7 * |
| 8 * <div some-directive probe="myProbe">..</div> | 8 * <div some-directive probe="myProbe">..</div> |
| 9 * | 9 * |
| 10 * rootScope.myProbe.directive(SomeAttrDirective); | 10 * rootScope.myProbe.directive(SomeAttrDirective); |
| 11 */ | 11 */ |
| 12 @Decorator(selector: '[probe]') | 12 @NgDirective(selector: '[probe]') |
| 13 class Probe implements DetachAware { | 13 class Probe implements NgDetachAware { |
| 14 final Scope scope; | 14 final Scope scope; |
| 15 final Injector injector; | 15 final Injector injector; |
| 16 final Element element; | 16 final Element element; |
| 17 String _probeName; | 17 final NodeAttrs _attrs; |
| 18 | 18 |
| 19 Probe(this.scope, this.injector, this.element) { | 19 Probe(this.scope, this.injector, this.element, this._attrs) { |
| 20 _probeName = element.attributes['probe']; | 20 scope.rootScope.context[_attrs['probe']] = this; |
| 21 scope.rootScope.context[_probeName] = this; | |
| 22 } | 21 } |
| 23 | 22 |
| 24 void detach() { | 23 void detach() { |
| 25 scope.rootScope.context[_probeName] = null; | 24 scope.rootScope.context[_attrs['probe']] = null; |
| 26 } | 25 } |
| 27 | 26 |
| 28 /** | 27 /** |
| 29 * Retrieve a Directive at the current element. | 28 * Retrieve a Directive at the current element. |
| 30 */ | 29 */ |
| 31 directive(Type type) => injector.get(type); | 30 directive(Type type) => injector.get(type); |
| 32 } | 31 } |
| 33 | 32 |
| OLD | NEW |