Ankur Shah
Ankur Shah

Reputation: 430

how can we remove relative path for images from an angular4 project?

I am working on Angular 4 project when ever i work in development environment relative path works fine but when we deploy our project it on test machine it does not find images path because in deployment server we have an extra directory.

For example our localhost url looks like below

http://localhost:10000/login

For test environment url look like below

http://servername:10000/projectname/login

Both url works fine and point to a login page if we use images through CSS it works see below.

icon-design {
    background-image: url('@{images}/indicator.svg');
}

Now I have actual problem that I have some drawing component which uses SVG internally and accept images through URL if we give image url as relative path it works for localhost like below

"../../../assets/img/1.png"

But same relative path does not work with test environment as test server url is little bit diffrent see above for URL?

Can any let me know how can we solve this issue?

Upvotes: 0

Views: 500

Answers (1)

J_H
J_H

Reputation: 20450

Rather than "/assets/img", use "./assets/img" to get relative URLs.

Upvotes: 1

Related Questions