diff --git a/src/ng/compile.js b/src/ng/compile.js
index 18adc2c9eff7..32c1d1cacd4c 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -735,9 +735,13 @@ function $CompileProvider($provide) {
scope[scopeName] = value;
});
attrs.$$observers[attrName].$$scope = parentScope;
+ if( attrs[attrName] ) {
+ // If the attribute has been provided then we trigger an interpolation to ensure the value is there for use in the link fn
+ scope[scopeName] = $interpolate(attrs[attrName])(parentScope);
+ }
break;
}
-
+
case '=': {
parentGet = $parse(attrs[attrName]);
parentSet = parentGet.assign || function() {
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js
index a7707cf9ee30..3b69f60925b9 100644
--- a/test/ng/compileSpec.js
+++ b/test/ng/compileSpec.js
@@ -1812,27 +1812,21 @@ describe('$compile', function() {
describe('attribute', function() {
it('should copy simple attribute', inject(function() {
compile('
');
- expect(componentScope.attr).toEqual(undefined);
- expect(componentScope.attrAlias).toEqual(undefined);
-
- $rootScope.$apply();
expect(componentScope.attr).toEqual('some text');
expect(componentScope.attrAlias).toEqual('some text');
expect(componentScope.attrAlias).toEqual(componentScope.attr);
}));
-
- it('should update when interpolated attribute updates', inject(function() {
- compile('');
- expect(componentScope.attr).toEqual(undefined);
- expect(componentScope.attrAlias).toEqual(undefined);
-
+ it('should set up the interpolation before it reaches the link function', inject(function() {
$rootScope.name = 'misko';
- $rootScope.$apply();
-
+ compile('');
expect(componentScope.attr).toEqual('hello misko');
expect(componentScope.attrAlias).toEqual('hello misko');
+ }));
+
+ it('should update when interpolated attribute updates', inject(function() {
+ compile('');
$rootScope.name = 'igor';
$rootScope.$apply();