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

182
Views
Quiero usar la variable URL de mi archivo environment.ts en mis servicios comunes, ¿cómo puedo leer esa variable?

Mi archivo de entorno

 export environment = { local: true, title: 'Local Environment Heading', API URL : 'http://localhost:8090/myapp/', staging: false, production: false, };

Archivo de servicio común

 // here I want to read this API URL
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En este caso, tiene un error en su archivo de entorno. Verifique que la URL de la API del nombre no pueda contener espacios en el nombre. Y olvidaste la const en la exportación. (Exportar entorno constante)

 export const environment = { local: true, title: 'Local Environment Heading', baseUrl : 'http://localhost:8090/myapp/', staging: false, production: false, };

Después de arreglar eso, es muy fácil de usar. Solo tienes que importar el archivo de entorno.

Por ejemplo en un servicio.

 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!