Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

177
Views
I want to use my environment.ts file URL variable in my common services, how can I read that variable?

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
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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
   }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!