My environment file
export environment = {
local: true,
title: 'Local Environment Heading',
API URL : 'http://localhost:8090/myapp/',
staging: false,
production: false,
};
Common service file
// here I want to read this API URL
In this case, you have an error on your enviroment file. Check the name API URL it couldn't contain space on the name. And you forgot the const on the export. (export const enviroment )
export const environment = {
local: true,
title: 'Local Environment Heading',
baseUrl : 'http://localhost:8090/myapp/',
staging: false,
production: false,
};
After fixing that, it's very simple to use. You just have to import the enviroment file.
For example in a service.
import { Injectable } from '@angular/core';
import { environment } from 'src/environments/environment';
@Injectable({
providedIn: 'root'
})
export class AuthServiceService {
constructor() {
const a = environment.baseUrl
}
}