fix(compile): Initialize interpolated attributes before directive linking

This commit is contained in:
Pete Bacon Darwin 2012-11-19 10:01:53 +00:00 committed by Misko Hevery
parent 2ed53087d7
commit bb8448c011
2 changed files with 4 additions and 3 deletions

View file

@ -1037,7 +1037,7 @@ function $CompileProvider($provide) {
interpolateFn = $interpolate(attr[name], true);
}
attr[name] = undefined;
attr[name] = interpolateFn(scope);
($$observers[name] || ($$observers[name] = [])).$$inter = true;
(attr.$$observers && attr.$$observers[name].$$scope || scope).
$watch(interpolateFn, function interpolateFnWatchAction(value) {

View file

@ -1381,9 +1381,10 @@ describe('$compile', function() {
}));
it('should set interpolated attrs to undefined', inject(function($rootScope, $compile) {
it('should set interpolated attrs to initial interpolation value', inject(function($rootScope, $compile) {
$rootScope.whatever = 'test value';
$compile('<div some-attr="{{whatever}}" observer></div>')($rootScope);
expect(directiveAttrs.someAttr).toBeUndefined();
expect(directiveAttrs.someAttr).toBe($rootScope.whatever);
}));