Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda