chanu1993 chanu1993 - 6 months ago 20
HTML Question

How to change img src in HTML using AngularJS without editing the HTML file?

I have a website done using AngularJS and all the HTML code is loading from database. So we cannot edit the code. It's loading when the application running. But we can edit the JavaScript files. So I have to edit the img src link. Actually I have to add some main url part to it. How can I do this ?

<img src="/img/logo.png"/> to <img src="http://demo.com/img/logo.png"/>


This is how this has to be done. No id in the img tag too. Can we use Angular Directives ? And we cannot add anything in the HTML files. No directive name too. Please help me on this. Really stuck in here.

Answer

If you're unable to edit the html file then it would be tricky to add angular directives. Have you thought about using jQuery to manipulate img source?