I've searched all over StackOverflow but I haven't been able to find a solution to my problem.
F.Y.I I'm using ASP.net Core 2.0's default angular project
I'm currently building an Angular application where I'm trying to load in a customer's logo based on a config found elsewhere.
I'm trying to load this file into my home.component.html
I created a "CustomerService" which has a function getLogo() which in itself returns the customer's logo's path.
My folder structure is as follows:
FOLDER STRUCTURE IMAGE
The assets folder holds the images, and the HTML found below is found in home.component.html
I know that "../../" isn't the way to go, so my first question is how I'd be able to fix that.
I've created the following HTML structure:
<img src="../../assets/timeblockr-logo.png" />
<img [src]="customerservice.getLogo()" />
And the CustomerService's getLogo function returns the following:
getLogo() {
return "../../assets/timeblockr-logo.png";
}
** EDIT: FOUND THE SOLUTION!!! **
Turns out I had to use:
getLogo(): string{
return require("../assets/timeblockr-logo.png");
}
Special thanks to @Niladri for the solution to this issue!