From 2f5dba488e855bcdbb9304aa809efcb9de7b43e9 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 3 Apr 2012 15:03:27 -0700 Subject: fix(ng-href): copy even if no binding Closes# 850 fixed an issue where ng-href would not copy its content into href if it did not contain binding. --- src/ng/directive/booleanAttrDirs.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/ng/directive/booleanAttrDirs.js') diff --git a/src/ng/directive/booleanAttrDirs.js b/src/ng/directive/booleanAttrDirs.js index f0182610..01134998 100644 --- a/src/ng/directive/booleanAttrDirs.js +++ b/src/ng/directive/booleanAttrDirs.js @@ -302,13 +302,21 @@ forEach(['src', 'href'], function(attrName) { var normalized = directiveNormalize('ng-' + attrName); ngAttributeAliasDirectives[normalized] = function() { return { - priority: 100, + priority: 99, // it needs to run after the attributes are interpolated compile: function(tpl, attr) { return function(scope, element, attr) { - attr.$$observers[attrName] = []; - attr.$observe(normalized, function(value) { + var value = attr[normalized]; + if (value == undefined) { + // undefined value means that the directive is being interpolated + // so just register observer + attr.$$observers[attrName] = []; + attr.$observe(normalized, function(value) { + attr.$set(attrName, value); + }); + } else { + // value present means that no interpolation, so copy to native attribute. attr.$set(attrName, value); - }); + } }; } }; -- cgit v1.2.3