Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($compile): rename $compileNote to compileNode
Browse files Browse the repository at this point in the history
Directives was observing different instances of Attributes than the one
that interpolation was registered with because we failed to realize
that the compile node and link node were the same (one of them
was a wrapper rather than raw node)

Closes #1941
  • Loading branch information
Enrique Paredes authored and IgorMinar committed Feb 7, 2013
1 parent 7090924 commit 92ca7ef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ function $CompileProvider($provide) {
}

directives.unshift(derivedSyncDirective);
afterTemplateNodeLinkFn = applyDirectivesToNode(directives, $compileNode, tAttrs, childTranscludeFn);
afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs, childTranscludeFn);
afterTemplateChildLinkFn = compileNodes($compileNode.contents(), childTranscludeFn);


Expand Down
19 changes: 19 additions & 0 deletions test/ng/compileSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,25 @@ describe('$compile', function() {
expect(element.text()).toEqual('WORKS');
});
});

it('should support $observe inside link function on directive object', function() {
module(function() {
directive('testLink', valueFn({
templateUrl: 'test-link.html',
link: function(scope, element, attrs) {
attrs.$observe( 'testLink', function ( val ) {
scope.testAttr = val;
});
}
}));
});
inject(function($compile, $rootScope, $templateCache) {
$templateCache.put('test-link.html', '{{testAttr}}' );
element = $compile('<div test-link="{{1+2}}"></div>')($rootScope);
$rootScope.$apply();
expect(element.text()).toBe('3');
});
});
});


Expand Down

0 comments on commit 92ca7ef

Please sign in to comment.