I'm trying to add ng-srcset to an image in link function. When i pass a constant string like "./temp/img3.jpg" it work correctly and add ng-srcset to my image.
link :function(scope,element){
element.attr("ng-srcset","./temp/img3.jpg");
$compile(element)(scope);
}
but when i try to pass a variable(checked and has a valid value) as attr value,ng-srcset not added to img.
link :function(scope,element){
//scope.imageSource => ./temp/img3.jpg
element.attr("ng-srcset",scope.imageSource);
$compile(element)(scope);
}
ng-srcsetvia a directive? Also, you can't invoke$compileon the same element (i.e. it's infinite recursion) the directive is applied to. Something else you haven't mentioned is likely causing you a problem because it's straight-forward enough to attachng-srcsetvia a directive — plnkr.co/edit/tMzfht01oLXaz0U3pLdf?p=previewng-srcsetsuggests it. Example of it in use: plnkr.co/edit/LGqE9FWZFePoCZIxC3hd?p=preview