mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-04 22:49:48 +08:00
fix($compile): rename $compileNote to compileNode
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
This commit is contained in:
committed by
Igor Minar
parent
7090924515
commit
92ca7efaa4
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user