diff options
| author | Igor Minar | 2012-01-15 23:26:06 -0800 |
|---|---|---|
| committer | Igor Minar | 2012-01-16 02:17:27 -0800 |
| commit | b587091b6e6a30a2c53d577956866a1e3d1c77ea (patch) | |
| tree | 8d12a67d59503b8b8ad67a907f3cbe5351daab56 | |
| parent | c49b8a2db5d916a9213547125af996d6c853230c (diff) | |
| download | angular.js-b587091b6e6a30a2c53d577956866a1e3d1c77ea.tar.bz2 | |
feat(jqLite): added injector() helper method
| -rw-r--r-- | src/Angular.js | 1 | ||||
| -rw-r--r-- | src/jqLite.js | 6 | ||||
| -rw-r--r-- | test/jqLiteSpec.js | 13 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/Angular.js b/src/Angular.js index 0f79d363..3f272ec2 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -923,6 +923,7 @@ function bindJQuery() { jqLite = jQuery; extend(jQuery.fn, { scope: JQLitePrototype.scope, + injector: JQLitePrototype.injector, inheritedData: JQLitePrototype.inheritedData }); JQLitePatchJQueryRemove('remove', true); diff --git a/src/jqLite.js b/src/jqLite.js index 1f640740..e7412904 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -59,6 +59,8 @@ * ## In addtion to the above, Angular privides an additional method to both jQuery and jQuery lite: * * - `scope()` - retrieves the current Angular scope of the element. + * - `injector()` - retrieves the Angular injector associated with application that the element is + * part of. * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top * parent element is reached. * @@ -314,6 +316,10 @@ forEach({ return jqLite(element).inheritedData($$scope); }, + injector: function(element) { + return jqLite(element).inheritedData('$injector'); + }, + removeAttr: function(element,name) { element.removeAttribute(name); }, diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 5c54e786..5936395e 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -138,6 +138,19 @@ describe('jqLite', function() { }); + describe('injector', function() { + it('should retrieve injector attached to the current element or its parent', function() { + var template = jqLite('<div><span></span></div>'), + span = template.children().eq(0), + injector = angular.bootstrap(template); + + + expect(span.injector()).toBe(injector); + dealoc(template); + }); + }); + + describe('data', function() { it('should set and get and remove data', function() { var selected = jqLite([a, b, c]); |
