angular2-app | example application for angular2 tutorial | Learning library
kandi X-RAY | angular2-app Summary
kandi X-RAY | angular2-app Summary
This repository is an example application for angular2 tutorial
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular2-app
angular2-app Key Features
angular2-app Examples and Code Snippets
Community Discussions
Trending Discussions on angular2-app
QUESTION
I am currently creating an angular application that uses a REST API
to send and receive calls from an instance at the backend. Currently, this URL is defined as an environment variable as below:
ANSWER
Answered 2020-Jul-15 at 07:17You can't really change the value of the environment directly in the code because it is bundled with everything else. It is also a really bad approach because you would overwrite the value everytime you update the application. Store it separately server-side!
Option A:
Use the APP_INITIALIZER and overwrite the value of the environment there, after loading it:
environment.api.host = loadedValue
That will only work properly if you don't use the value before that. It would only be used before that if you use it in module definitions / configuration and classes that you inject into the initializer. So that might work for you.
Option B
This is rather ugly but would work fine:
Save the api url in a separate javascript file that looks somewhat like this:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular2-app
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page