From 0e50810c53428f4c1f5bfdba9599df54cb7a6c6e Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Fri, 29 Nov 2013 21:02:00 -0500 Subject: fix(ngInit): evaluate ngInit before ngInclude The priority of ngInit is adjusted to occur before ngInclude, and after ngController. This enables ngInit to initiallize values in a controller's scope, and also to initiallize values before ngInclude executes. Closes #5167 Closes #5208 --- test/ng/directive/ngInitSpec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'test/ng/directive') diff --git a/test/ng/directive/ngInitSpec.js b/test/ng/directive/ngInitSpec.js index 00038621..9ed930ad 100644 --- a/test/ng/directive/ngInitSpec.js +++ b/test/ng/directive/ngInitSpec.js @@ -13,4 +13,30 @@ describe('ngInit', function() { element = $compile('
')($rootScope); expect($rootScope.a).toEqual(123); })); + + + it("should be evaluated before ngInclude", inject(function($rootScope, $templateCache, $compile) { + $templateCache.put('template1.tpl', '1'); + $templateCache.put('template2.tpl', '2'); + $rootScope.template = 'template1.tpl'; + element = $compile('
')($rootScope); + $rootScope.$digest(); + expect($rootScope.template).toEqual('template2.tpl'); + expect(element.find('span').text()).toEqual('2'); + })); + + + it("should be evaluated after ngController", function() { + module(function($controllerProvider) { + $controllerProvider.register('TestCtrl', function($scope) {}); + }); + inject(function($rootScope, $compile) { + element = $compile('
')($rootScope); + $rootScope.$digest(); + expect($rootScope.test).toBeUndefined(); + expect(element.children('div').scope().test).toEqual(123); + }); + }); }); -- cgit v1.2.3