Categories

Sunday, February 5, 2023
+919814419350 therichposts@gmail.com
AngularAngular 15

Set & Get Base URL for Images in Angular 15

Set & Get Base URL for Images in Angular 15
321

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.

therichpost
the authortherichpost
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 8, Angular 9, Angular 10, Angular 11, Angular12, Angular 13, Angular 14, Angular 15, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

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