SlideShare a Scribd company logo
Presented By:
Devanshu Verma & Amar
Environment Variables
in Angular
Lack of etiquette and manners is a huge turn off.
Session Etiquettes
Punctuality
Respect session timings, you
are requested not to join
sessions after a 5 minutes
threshold post the session
start time.
Feedback
Make sure to submit a
constructive feedback for all
sessions as it is very helpful
for the presenter.
Silent Mode
Keep your mobile devices in
silent mode, feel free to
move out of session in case
you need to attend an
urgent call.
Avoid Disturbance
Avoid unwanted chit chat
during the session.
Our Agenda
02
01
03
How To Read the Environment Variables
04
Where is Angular Environment Variables
How to Create Environment Variables
Introduction
05
Configuration of angular.json
06
Testing the Environment Variable
07 Demo
INTRODUCTION
● Environment Variables are those variables, whose value
changes as per the environment we are in.
● Development, testing, staging and production are the
stages of product development. We call these stages as
environment
● Environment Variable will helps you to define your static
variable in your application and it will different value of
variable our app will run on live and local.
Where is Angular Environment Variables
Angular provides build-in support to configure and manage Environment Variables.
It keeps the environment configuration under the folder src/environments folder.
Where is Angular Environment Variables…
As we can see above folder contains two files one is environment.ts and the other one is
environment.prod.ts If we open the above files the we will be able to see the following code.
// environment.ts
export const environment = {
production: false
};
// environment.prod.ts
export const environment = {
production: true
};
The above file contains only one variable i.e., production, which is true in environment.prod.ts
and false in environment.ts.
How to Create Environment Variables
Creating an environment variable is very simple we just need to add new environment in all
the environment files.
For Example we want a variable environment_name which gives is the name of the current
environment the we just need to add this variable to each and every environment files as
shown below
// environment.ts
export const environments = {
production: false,
environment_name :
'local/development'
}
// environment.prod.ts
export class environments = {
production: true,
environment_name :
'production'
}
How To Read the Environment Variable
● Now that we have our new Environment
Variables in place. We must be wondering how
we are going to read those variables in our app
and use them.
● So to use our environment variables we need to
import the default environment file in our
component like : import {environment} from
'../environments/environment';
NOTE : We don’t have to import any other file
environment.prod.ts in our component. We just
need to import the default environment file.
export class AppComponent implements OnInit
{
currentEnvironment !: string;
constructor() {
this.currentEnvironment =
environment.environment_name;
}
ngOnInit() {
console.log('Current Environment is
', this.currentEnvironment);
}
}
Testing the Environment Variable
Now when we have created our environment variable and also imported and used it it our application, it's time to
test whether our environment variables are actually working or not. For testing we will be using ng serve command
with different configuration and we will be able to see the console having different output in different configs.
ng serve
ng serve --configuration="production"
The above command will console Current Environment is local/development since by default it uses development
for serving the app.
The above command will console Current Environment is production.
Configuration of angular.json
● We need to configure or angular.json to let
angular know on which configuration which
environment it needs to pick and replace.
● angular.json initially holds two configuration -
○ production
○ development
● In production environment with the help of config
angular knows that i need to replace
environment.ts with environment.prod.ts
● In development environment, environment.ts will
be replaced by environment.stag.ts
DEMO
Resources
● https://angular.io/guide/build
● https://blog.knoldus.com/environment-variables-in-angular-part-
1/#where-is-angular-environment-variables
Thank You !
Get in touch with us:
Lorem Studio, Lord Building
D4456, LA, USA

More Related Content

What's hot

【解説】データ指向アプリケーションデザイン 12章 データシステムの未来
【解説】データ指向アプリケーションデザイン 12章 データシステムの未来【解説】データ指向アプリケーションデザイン 12章 データシステムの未来
【解説】データ指向アプリケーションデザイン 12章 データシステムの未来
Shinya Mori (@mosuke5)
 
DockerとDocker Hubの操作と概念
DockerとDocker Hubの操作と概念DockerとDocker Hubの操作と概念
DockerとDocker Hubの操作と概念
Masahito Zembutsu
 
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
Simplilearn
 
[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura
[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura
[B24] Oracle から SQL Server システム移行の勘所 by Norio NakamuraInsight Technology, Inc.
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
Jiwon Baek
 
Pl sql student guide v 4
Pl sql student guide v 4Pl sql student guide v 4
Pl sql student guide v 4
Nexus
 
Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션Dabi Ahn
 
Tutorial Git
Tutorial GitTutorial Git
Git training v10
Git training v10Git training v10
Git training v10
Skander Hamza
 
d.ts 만들기
d.ts 만들기d.ts 만들기
d.ts 만들기
DaeSeon Jeong
 
Ansible
AnsibleAnsible
Ansible
Knoldus Inc.
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
John Willis
 
Android カスタムROMの作り方
Android カスタムROMの作り方Android カスタムROMの作り方
Android カスタムROMの作り方
Masahiro Hidaka
 
Final terraform
Final terraformFinal terraform
Final terraform
Gourav Varma
 
Docker basics
Docker basicsDocker basics
Docker basics
AmanSoni129
 
Git.pptx
Git.pptxGit.pptx
Viveはじめました
ViveはじめましたViveはじめました
Viveはじめました
Kojiro Yano
 
Quarkus Technical Deep Dive - Japanese
Quarkus Technical Deep Dive - JapaneseQuarkus Technical Deep Dive - Japanese
Quarkus Technical Deep Dive - Japanese
Chihiro Ito
 
[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버
[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버
[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버
준철 박
 
(Tech DeepDive #1) Java Flight Recorder を活用した問題解決
(Tech DeepDive #1) Java Flight Recorder を活用した問題解決(Tech DeepDive #1) Java Flight Recorder を活用した問題解決
(Tech DeepDive #1) Java Flight Recorder を活用した問題解決
オラクルエンジニア通信
 

What's hot (20)

【解説】データ指向アプリケーションデザイン 12章 データシステムの未来
【解説】データ指向アプリケーションデザイン 12章 データシステムの未来【解説】データ指向アプリケーションデザイン 12章 データシステムの未来
【解説】データ指向アプリケーションデザイン 12章 データシステムの未来
 
DockerとDocker Hubの操作と概念
DockerとDocker Hubの操作と概念DockerとDocker Hubの操作と概念
DockerとDocker Hubの操作と概念
 
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
DevOps Interview Questions Part - 1 | Devops Interview Questions And Answers ...
 
[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura
[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura
[B24] Oracle から SQL Server システム移行の勘所 by Norio Nakamura
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Pl sql student guide v 4
Pl sql student guide v 4Pl sql student guide v 4
Pl sql student guide v 4
 
Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션Git 기본개념과 사용법 그리고 어플리케이션
Git 기본개념과 사용법 그리고 어플리케이션
 
Tutorial Git
Tutorial GitTutorial Git
Tutorial Git
 
Git training v10
Git training v10Git training v10
Git training v10
 
d.ts 만들기
d.ts 만들기d.ts 만들기
d.ts 만들기
 
Ansible
AnsibleAnsible
Ansible
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
Android カスタムROMの作り方
Android カスタムROMの作り方Android カスタムROMの作り方
Android カスタムROMの作り方
 
Final terraform
Final terraformFinal terraform
Final terraform
 
Docker basics
Docker basicsDocker basics
Docker basics
 
Git.pptx
Git.pptxGit.pptx
Git.pptx
 
Viveはじめました
ViveはじめましたViveはじめました
Viveはじめました
 
Quarkus Technical Deep Dive - Japanese
Quarkus Technical Deep Dive - JapaneseQuarkus Technical Deep Dive - Japanese
Quarkus Technical Deep Dive - Japanese
 
[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버
[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버
[NDC2017 : 박준철] Python 게임 서버 안녕하십니까 - 몬스터 슈퍼리그 게임 서버
 
(Tech DeepDive #1) Java Flight Recorder を活用した問題解決
(Tech DeepDive #1) Java Flight Recorder を活用した問題解決(Tech DeepDive #1) Java Flight Recorder を活用した問題解決
(Tech DeepDive #1) Java Flight Recorder を活用した問題解決
 

Similar to Environment Variables in Angular

Python Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for BeginnersPython Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for Beginners
Inexture Solutions
 
How to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooksHow to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooks
Katy Slemon
 
Modern app development with Jetpack Compose.pptx
Modern app development with Jetpack Compose.pptxModern app development with Jetpack Compose.pptx
Modern app development with Jetpack Compose.pptx
Md Shamsul Arafin Mahtab
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
Keith Bloomfield
 
Angular Multi-env Setup
Angular Multi-env SetupAngular Multi-env Setup
Angular Multi-env Setup
Knoldus Inc.
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
JohnLeo57
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
Coding Academy
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
Keith Bloomfield
 
Práticas, Técnicas e Ferramentas para Continuous Delivery com ALM
Práticas, Técnicas e Ferramentas para Continuous Delivery com ALMPráticas, Técnicas e Ferramentas para Continuous Delivery com ALM
Práticas, Técnicas e Ferramentas para Continuous Delivery com ALM
Marcelo Sousa Ancelmo
 
OSGi Semantic Versioning with Baselining in enRoute - P Kriens
OSGi Semantic Versioning with Baselining in enRoute - P KriensOSGi Semantic Versioning with Baselining in enRoute - P Kriens
OSGi Semantic Versioning with Baselining in enRoute - P Kriens
mfrancis
 
Contact management system
Contact management systemContact management system
Contact management system
SHARDA SHARAN
 
React Hooks
React HooksReact Hooks
React Hooks
Erez Cohen
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
Knoldus Inc.
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
Ravi Mone
 
Uncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applicationsUncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applications
Kazuaki Matsuo
 
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for KubernetesDocker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Andrew Phillips
 
Testing level
Testing levelTesting level
Testing level
zahid7578
 
Cold fusion best practice
Cold fusion best practiceCold fusion best practice
Cold fusion best practice
isummation
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
Akhil Mittal
 

Similar to Environment Variables in Angular (20)

Python Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for BeginnersPython Environment Variables A Step-by-Step Tutorial for Beginners
Python Environment Variables A Step-by-Step Tutorial for Beginners
 
How to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooksHow to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooks
 
Modern app development with Jetpack Compose.pptx
Modern app development with Jetpack Compose.pptxModern app development with Jetpack Compose.pptx
Modern app development with Jetpack Compose.pptx
 
AngularJs Crash Course
AngularJs Crash CourseAngularJs Crash Course
AngularJs Crash Course
 
Angular Multi-env Setup
Angular Multi-env SetupAngular Multi-env Setup
Angular Multi-env Setup
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Angular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdfAngular Interview Questions-PDF.pdf
Angular Interview Questions-PDF.pdf
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
Angular js-crash-course
Angular js-crash-courseAngular js-crash-course
Angular js-crash-course
 
Práticas, Técnicas e Ferramentas para Continuous Delivery com ALM
Práticas, Técnicas e Ferramentas para Continuous Delivery com ALMPráticas, Técnicas e Ferramentas para Continuous Delivery com ALM
Práticas, Técnicas e Ferramentas para Continuous Delivery com ALM
 
OSGi Semantic Versioning with Baselining in enRoute - P Kriens
OSGi Semantic Versioning with Baselining in enRoute - P KriensOSGi Semantic Versioning with Baselining in enRoute - P Kriens
OSGi Semantic Versioning with Baselining in enRoute - P Kriens
 
Contact management system
Contact management systemContact management system
Contact management system
 
React Hooks
React HooksReact Hooks
React Hooks
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
 
Angular2 with type script
Angular2 with type scriptAngular2 with type script
Angular2 with type script
 
Uncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applicationsUncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applications
 
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for KubernetesDocker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
Docker New York City: From GitOps to a scalable CI/CD Pattern for Kubernetes
 
Testing level
Testing levelTesting level
Testing level
 
Cold fusion best practice
Cold fusion best practiceCold fusion best practice
Cold fusion best practice
 
Diving into VS 2015 Day5
Diving into VS 2015 Day5Diving into VS 2015 Day5
Diving into VS 2015 Day5
 

More from Knoldus Inc.

Terratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructureTerratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructure
Knoldus Inc.
 
Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
Knoldus Inc.
 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
Knoldus Inc.
 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
Knoldus Inc.
 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
Knoldus Inc.
 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
Knoldus Inc.
 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
Knoldus Inc.
 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
Knoldus Inc.
 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
Knoldus Inc.
 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
Knoldus Inc.
 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
Knoldus Inc.
 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
Knoldus Inc.
 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
Knoldus Inc.
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
Knoldus Inc.
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
Knoldus Inc.
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
Knoldus Inc.
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
Knoldus Inc.
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Knoldus Inc.
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
Knoldus Inc.
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
Knoldus Inc.
 

More from Knoldus Inc. (20)

Terratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructureTerratest - Automation testing of infrastructure
Terratest - Automation testing of infrastructure
 
Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)Getting Started with Apache Spark (Scala)
Getting Started with Apache Spark (Scala)
 
Secure practices with dot net services.pptx
Secure practices with dot net services.pptxSecure practices with dot net services.pptx
Secure practices with dot net services.pptx
 
Distributed Cache with dot microservices
Distributed Cache with dot microservicesDistributed Cache with dot microservices
Distributed Cache with dot microservices
 
Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)Introduction to gRPC Presentation (Java)
Introduction to gRPC Presentation (Java)
 
Using InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in JmeterUsing InfluxDB for real-time monitoring in Jmeter
Using InfluxDB for real-time monitoring in Jmeter
 
Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)Intoduction to KubeVela Presentation (DevOps)
Intoduction to KubeVela Presentation (DevOps)
 
Stakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) PresentationStakeholder Management (Project Management) Presentation
Stakeholder Management (Project Management) Presentation
 
Introduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) PresentationIntroduction To Kaniko (DevOps) Presentation
Introduction To Kaniko (DevOps) Presentation
 
Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)Efficient Test Environments with Infrastructure as Code (IaC)
Efficient Test Environments with Infrastructure as Code (IaC)
 
Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)Exploring Terramate DevOps (Presentation)
Exploring Terramate DevOps (Presentation)
 
Clean Code in Test Automation Differentiating Between the Good and the Bad
Clean Code in Test Automation  Differentiating Between the Good and the BadClean Code in Test Automation  Differentiating Between the Good and the Bad
Clean Code in Test Automation Differentiating Between the Good and the Bad
 
Integrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test AutomationIntegrating AI Capabilities in Test Automation
Integrating AI Capabilities in Test Automation
 
State Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptxState Management with NGXS in Angular.pptx
State Management with NGXS in Angular.pptx
 
Authentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptxAuthentication in Svelte using cookies.pptx
Authentication in Svelte using cookies.pptx
 
OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)OAuth2 Implementation Presentation (Java)
OAuth2 Implementation Presentation (Java)
 
Supply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptxSupply chain security with Kubeclarity.pptx
Supply chain security with Kubeclarity.pptx
 
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML ParsingMastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
Mastering Web Scraping with JSoup Unlocking the Secrets of HTML Parsing
 
Akka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On IntroductionAkka gRPC Essentials A Hands-On Introduction
Akka gRPC Essentials A Hands-On Introduction
 
Entity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptxEntity Core with Core Microservices.pptx
Entity Core with Core Microservices.pptx
 

Recently uploaded

Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
Hiike
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
Wouter Lemaire
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
Postman
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Safe Software
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
alexjohnson7307
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
SitimaJohn
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
fredae14
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Wask
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 

Recently uploaded (20)

Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - HiikeSystem Design Case Study: Building a Scalable E-Commerce Platform - Hiike
System Design Case Study: Building a Scalable E-Commerce Platform - Hiike
 
UI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentationUI5 Controls simplified - UI5con2024 presentation
UI5 Controls simplified - UI5con2024 presentation
 
WeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation TechniquesWeTestAthens: Postman's AI & Automation Techniques
WeTestAthens: Postman's AI & Automation Techniques
 
Driving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success StoryDriving Business Innovation: Latest Generative AI Advancements & Success Story
Driving Business Innovation: Latest Generative AI Advancements & Success Story
 
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
leewayhertz.com-AI in predictive maintenance Use cases technologies benefits ...
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptxOcean lotus Threat actors project by John Sitima 2024 (1).pptx
Ocean lotus Threat actors project by John Sitima 2024 (1).pptx
 
Recommendation System using RAG Architecture
Recommendation System using RAG ArchitectureRecommendation System using RAG Architecture
Recommendation System using RAG Architecture
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Digital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying AheadDigital Marketing Trends in 2024 | Guide for Staying Ahead
Digital Marketing Trends in 2024 | Guide for Staying Ahead
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 

Environment Variables in Angular

  • 1. Presented By: Devanshu Verma & Amar Environment Variables in Angular
  • 2. Lack of etiquette and manners is a huge turn off. Session Etiquettes Punctuality Respect session timings, you are requested not to join sessions after a 5 minutes threshold post the session start time. Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter. Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call. Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3. Our Agenda 02 01 03 How To Read the Environment Variables 04 Where is Angular Environment Variables How to Create Environment Variables Introduction 05 Configuration of angular.json 06 Testing the Environment Variable 07 Demo
  • 4. INTRODUCTION ● Environment Variables are those variables, whose value changes as per the environment we are in. ● Development, testing, staging and production are the stages of product development. We call these stages as environment ● Environment Variable will helps you to define your static variable in your application and it will different value of variable our app will run on live and local.
  • 5. Where is Angular Environment Variables Angular provides build-in support to configure and manage Environment Variables. It keeps the environment configuration under the folder src/environments folder.
  • 6. Where is Angular Environment Variables… As we can see above folder contains two files one is environment.ts and the other one is environment.prod.ts If we open the above files the we will be able to see the following code. // environment.ts export const environment = { production: false }; // environment.prod.ts export const environment = { production: true }; The above file contains only one variable i.e., production, which is true in environment.prod.ts and false in environment.ts.
  • 7. How to Create Environment Variables Creating an environment variable is very simple we just need to add new environment in all the environment files. For Example we want a variable environment_name which gives is the name of the current environment the we just need to add this variable to each and every environment files as shown below // environment.ts export const environments = { production: false, environment_name : 'local/development' } // environment.prod.ts export class environments = { production: true, environment_name : 'production' }
  • 8. How To Read the Environment Variable ● Now that we have our new Environment Variables in place. We must be wondering how we are going to read those variables in our app and use them. ● So to use our environment variables we need to import the default environment file in our component like : import {environment} from '../environments/environment'; NOTE : We don’t have to import any other file environment.prod.ts in our component. We just need to import the default environment file. export class AppComponent implements OnInit { currentEnvironment !: string; constructor() { this.currentEnvironment = environment.environment_name; } ngOnInit() { console.log('Current Environment is ', this.currentEnvironment); } }
  • 9. Testing the Environment Variable Now when we have created our environment variable and also imported and used it it our application, it's time to test whether our environment variables are actually working or not. For testing we will be using ng serve command with different configuration and we will be able to see the console having different output in different configs. ng serve ng serve --configuration="production" The above command will console Current Environment is local/development since by default it uses development for serving the app. The above command will console Current Environment is production.
  • 10. Configuration of angular.json ● We need to configure or angular.json to let angular know on which configuration which environment it needs to pick and replace. ● angular.json initially holds two configuration - ○ production ○ development ● In production environment with the help of config angular knows that i need to replace environment.ts with environment.prod.ts ● In development environment, environment.ts will be replaced by environment.stag.ts
  • 11. DEMO
  • 13. Thank You ! Get in touch with us: Lorem Studio, Lord Building D4456, LA, USA