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 --- src/ng/directive/ngInit.js | 3 +++ test/ng/directive/ngInitSpec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/ng/directive/ngInit.js b/src/ng/directive/ngInit.js index d3d0f3c1..934b31cc 100644 --- a/src/ng/directive/ngInit.js +++ b/src/ng/directive/ngInit.js @@ -16,6 +16,8 @@ * to initialize values on a scope. * * + * @priority 450 + * * @element ANY * @param {expression} ngInit {@link guide/expression Expression} to eval. * @@ -47,6 +49,7 @@ */ var ngInitDirective = ngDirective({ + priority: 450, compile: function() { return { pre: function(scope, element, attrs) { 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('