aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/compileSpec.js
diff options
context:
space:
mode:
authorChirayu Krishnappa2013-08-09 19:56:10 -0700
committerChirayu Krishnappa2013-08-20 18:51:07 -0700
commit51d32243fe8cfbdcd1b647950d4e99ed57677558 (patch)
treeb50d179ba51cdb8b4e6eb4fcdba90607b25cd11f /test/ng/compileSpec.js
parent1c1a1bc9eda5497010506d16fe4f1b5e224d289e (diff)
downloadangular.js-51d32243fe8cfbdcd1b647950d4e99ed57677558.tar.bz2
fix($compile): correct controller instantiation for async directives
This fixes regression introduced by #3514 (9c51d503) - this commit is being reverted here and a better fix is included. The regression caused the controller to be instantiated before the isolate scope was initialized. Closes #3493 Closes #3482 Closes #3537 Closes #3540
Diffstat (limited to 'test/ng/compileSpec.js')
-rwxr-xr-xtest/ng/compileSpec.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index 93fe6ced..c998cda8 100755
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -2258,6 +2258,61 @@ describe('$compile', function() {
});
+ it('should instantiate the controller after the isolate scope bindings are initialized (with template)', function () {
+ module(function () {
+ var Ctrl = function ($scope, log) {
+ log('myFoo=' + $scope.myFoo);
+ };
+
+ directive('myDirective', function () {
+ return {
+ scope: {
+ myFoo: "="
+ },
+ template: '<p>Hello</p>',
+ controller: Ctrl
+ };
+ });
+ });
+
+ inject(function ($templateCache, $compile, $rootScope, log) {
+ $rootScope.foo = "bar";
+
+ element = $compile('<div my-directive my-foo="foo"></div>')($rootScope);
+ $rootScope.$apply();
+ expect(log).toEqual('myFoo=bar');
+ });
+ });
+
+
+ it('should instantiate the controller after the isolate scope bindings are initialized (with templateUrl)', function () {
+ module(function () {
+ var Ctrl = function ($scope, log) {
+ log('myFoo=' + $scope.myFoo);
+ };
+
+ directive('myDirective', function () {
+ return {
+ scope: {
+ myFoo: "="
+ },
+ templateUrl: 'hello.html',
+ controller: Ctrl
+ };
+ });
+ });
+
+ inject(function ($templateCache, $compile, $rootScope, log) {
+ $templateCache.put('hello.html', '<p>Hello</p>');
+ $rootScope.foo = "bar";
+
+ element = $compile('<div my-directive my-foo="foo"></div>')($rootScope);
+ $rootScope.$apply();
+ expect(log).toEqual('myFoo=bar');
+ });
+ });
+
+
it('should instantiate controllers in the parent->child->baby order when nested transluction, templateUrl and ' +
'replacement are in the mix', function() {
// similar to the test above, except that we have one more layer of nesting and nested transclusion