Set & Get Base URL for Images in Angular 15Set & 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.

By therichpost

Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

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