Home Angular Set & Get Base URL for Images in Angular 15

Set & Get Base URL for Images in Angular 15

by therichpost
0 comments
Set & Get Base URL for Images in Angular 15

Hello to all, welcome to therichpost.com. In this post, I will tell you, Set & Get Base URL for Images in Angular 15.

Live demo

Guy’s Angular 15 came and if you are new in Angular 15 then please check below links:

  1. Angular 15 Tutorials
  2. Angular Free Templates

Here is the working code snippet and please follow carefully:

1. Now you need to add below code into your src/environments/environments.ts file:

export const environment = {
  ...
  imageURL:"assets/images"
};

2. Now you need to add below code into your src/app/app.component.ts file:

...
import { environment } from 'src/environments/environment';


export class AppComponent {
  ...
  imageURL = environment.imageURL;

}

3. Now you need to add below code into src/app/app.component.html file:

<img [src]="imageURL+'/imagename'"/>

In the end, don’t forgot to run ng serve command. If you have any query then do comment below.

Note: Friends, I just tell the basic setup and things, you can change the code according to your requirements. For better understanding please watch the above video.

I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad.

Jassa

Thank you.

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.