Hi, I am working on a directive where I need to edit the DOM by adding the ng-src attribute and model to it.
This is my DOM
<edit-component>
<img src="images/logo.png" title="Hearty Wear" />
</edit-component>
I need a DOM be result
`<div>
<img src="images/logo.png" title="Hearty Wear" ng-src={{myModel}} />
</div> `
That way, when I update myModel with data, the image should be updated
UPDATE
sam.directive('editComponent', function() {
return {
restrict: 'EA',
transclude: true,
replace: true,
templateUrl: "imageTemplate.html",
link: function(scope, element, attb, ctrl, transclude) {
scope.data = function() {
var imagedata;
imagedata = arguments[5];
scope.imageModel = imagedata.base64;
return element.find('img').attr('src', "data:image/png;base64," + imagedata.base64);
};
}
};
});
I need the previous src attribute value to display an existing image.
I am currently updating the src attribute manually. I need a solution where I can update using the model variable
thank