From 8006fab88c875eb138be5feb2e308953d12c48f6 Mon Sep 17 00:00:00 2001 From: Stephen Bunch Date: Fri, 1 Aug 2014 19:16:45 -0700 Subject: [PATCH 1/3] add template url argument to $includeContentRequested event --- src/ng/directive/ngInclude.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js index 7b0d020bf5f2..7731bd3dc76a 100644 --- a/src/ng/directive/ngInclude.js +++ b/src/ng/directive/ngInclude.js @@ -234,7 +234,7 @@ var ngIncludeDirective = ['$http', '$templateCache', '$anchorScroll', '$animate' currentScope = newScope; currentElement = clone; - currentScope.$emit('$includeContentLoaded'); + currentScope.$emit('$includeContentLoaded', src); scope.$eval(onloadExp); }).error(function() { if (thisChangeId === changeCounter) { From 1b1c3dcdc5782568415785c848af56a725a5f403 Mon Sep 17 00:00:00 2001 From: Stephen Bunch Date: Mon, 18 Aug 2014 11:36:46 -0700 Subject: [PATCH 2/3] add docs and test for $includeContentRequest `src` argument feature #8454 --- src/ng/directive/ngInclude.js | 3 +++ test/ng/directive/ngIncludeSpec.js | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/ng/directive/ngInclude.js b/src/ng/directive/ngInclude.js index 7731bd3dc76a..d041d6d86255 100644 --- a/src/ng/directive/ngInclude.js +++ b/src/ng/directive/ngInclude.js @@ -159,6 +159,9 @@ * @eventType emit on the current ngInclude scope * @description * Emitted every time the ngInclude content is reloaded. + * + * @param {Object} angularEvent Synthetic event object. + * @param {String} src Source URL. */ diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 828c6d2056fb..0f676ccc32fd 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -360,6 +360,17 @@ describe('ngInclude', function() { } catch (e) {} })); + it('should fire $includeContentLoaded with the template url as the second parameter', inject(function($rootScope, $compile, $templateCache) { + var called = 0; + $templateCache.put('/some/template.html', [200, '', {}]); + $rootScope.$on('$includeContentLoaded', function(event, src) { + expect(src).toBe('/some/template.html'); + called++; + }); + element = $compile('
')($rootScope); + $rootScope.$digest(); + expect(called).toBe(1); + })); describe('autoscroll', function() { var autoScrollSpy; From 66f077c772d57ae62d0846a0d88f08567902bd1e Mon Sep 17 00:00:00 2001 From: Stephen Bunch Date: Tue, 19 Aug 2014 08:00:17 -0700 Subject: [PATCH 3/3] update test to use jasmine spy #8454 --- test/ng/directive/ngIncludeSpec.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/ng/directive/ngIncludeSpec.js b/test/ng/directive/ngIncludeSpec.js index 0f676ccc32fd..35bbb16bfac0 100644 --- a/test/ng/directive/ngIncludeSpec.js +++ b/test/ng/directive/ngIncludeSpec.js @@ -361,15 +361,12 @@ describe('ngInclude', function() { })); it('should fire $includeContentLoaded with the template url as the second parameter', inject(function($rootScope, $compile, $templateCache) { - var called = 0; + var handlerSpy = jasmine.createSpy('handler'); $templateCache.put('/some/template.html', [200, '', {}]); - $rootScope.$on('$includeContentLoaded', function(event, src) { - expect(src).toBe('/some/template.html'); - called++; - }); + $rootScope.$on('$includeContentLoaded', handlerSpy); element = $compile('
')($rootScope); $rootScope.$digest(); - expect(called).toBe(1); + expect(handlerSpy).toHaveBeenCalledWith(jasmine.any(Object), '/some/template.html'); })); describe('autoscroll', function() {