From d551d72924f7c43a043e4760ff05d7389e310f99 Mon Sep 17 00:00:00 2001 From: Samuel Santos Date: Tue, 7 May 2013 17:45:28 +0100 Subject: feat(ngSrcset): add new ngSrcset directive In line with ngSrc and ngHref, this new directive ensures that the `srcset` HTML5 attribute does not include a pre-interpolated string. Without it the browser will fetch from the URL with the literal text `{{hash}}` until AngularJS replaces the expression inside `{{hash}}`. Closes #2601 --- src/ng/directive/booleanAttrs.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ng/directive/booleanAttrs.js b/src/ng/directive/booleanAttrs.js index 7e0e3a42..8f7399a6 100644 --- a/src/ng/directive/booleanAttrs.js +++ b/src/ng/directive/booleanAttrs.js @@ -105,6 +105,31 @@ * @param {template} ngSrc any string which can contain `{{}}` markup. */ +/** + * @ngdoc directive + * @name ng.directive:ngSrcset + * @restrict A + * + * @description + * Using Angular markup like `{{hash}}` in a `srcset` attribute doesn't + * work right: The browser will fetch from the URL with the literal + * text `{{hash}}` until Angular replaces the expression inside + * `{{hash}}`. The `ngSrcset` directive solves this problem. + * + * The buggy way to write it: + *
+ * 
+ * 
+ * + * The correct way to write it: + *
+ * 
+ * 
+ * + * @element IMG + * @param {template} ngSrcset any string which can contain `{{}}` markup. + */ + /** * @ngdoc directive * @name ng.directive:ngDisabled @@ -325,8 +350,8 @@ forEach(BOOLEAN_ATTR, function(propName, attrName) { }); -// ng-src, ng-href are interpolated -forEach(['src', 'href'], function(attrName) { +// ng-src, ng-srcset, ng-href are interpolated +forEach(['src', 'srcset', 'href'], function(attrName) { var normalized = directiveNormalize('ng-' + attrName); ngAttributeAliasDirectives[normalized] = function() { return { -- cgit v1.2.3