<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ankit Kumar Sharma</title>
    <description>The latest articles on DEV Community by Ankit Kumar Sharma (@ankit_k_sharma).</description>
    <link>https://dev.to/ankit_k_sharma</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F841068%2F2c727b62-b515-493a-ae89-d174b09e087d.jpeg</url>
      <title>DEV Community: Ankit Kumar Sharma</title>
      <link>https://dev.to/ankit_k_sharma</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ankit_k_sharma"/>
    <language>en</language>
    <item>
      <title>Hoisting in Java Script</title>
      <dc:creator>Ankit Kumar Sharma</dc:creator>
      <pubDate>Mon, 11 Jul 2022 18:11:35 +0000</pubDate>
      <link>https://dev.to/ankit_k_sharma/hoisting-in-java-script-37a0</link>
      <guid>https://dev.to/ankit_k_sharma/hoisting-in-java-script-37a0</guid>
      <description>&lt;p&gt;Nowadays, Java script is the most popular language in the world. If you are a fresher or experienced, then you should know, what is &lt;code&gt;Java Script Hoisting&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;In mostly technical interviews, that question frequently asked by interviewer but lack of knowledge, mostly guys don’t explain correctly. So, today I am explaining in very sufficient way.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D0H-Wcim--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2nwhofup44f89s42fym.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D0H-Wcim--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2nwhofup44f89s42fym.jpg" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before hoisting, I am talking about, &lt;strong&gt;what is Global Execution Context?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Global Execution Context —
&lt;/h2&gt;

&lt;p&gt;It is a process that run and contain the whole code and create a global scope for variables and functions in two phase&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Memory Creation —&lt;/strong&gt; This is a part of hoisting behaviour in java script, where global execution allocate memory to each variable and function&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Code Execution —&lt;/strong&gt; This is the part of execute that code will execute and allocate provided value to variables &amp;amp; functions if required, also this part can have inner sub execution context part for functions.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What is Hoisting ?
&lt;/h2&gt;

&lt;p&gt;Hoisting is a process that access &lt;code&gt;variables&lt;/code&gt; and &lt;code&gt;functions&lt;/code&gt; before you have initialized or declared. It is a java script’s default behaviour of moving all declaration to the of the global execution scope.&lt;/p&gt;

&lt;p&gt;Java Script create a global execution space for declare variable and function to allocate memory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Variable hoisting
&lt;/h3&gt;

&lt;p&gt;we can use a variable in code before it is declared or initialized. if we have not declared any value before use of that variable, it allocates &lt;code&gt;undefined&lt;/code&gt; to that particular variable.&lt;/p&gt;

&lt;p&gt;If we talking about variables and constants, keyword &lt;code&gt;var&lt;/code&gt; is hoisted and &lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; does not allow hoisting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(x) // undefined
console.log(y) // undefined
var x = 7;
var y;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Function hoisting
&lt;/h2&gt;

&lt;p&gt;It lets you use a function before you declare it in your code, it works as function will defined as you have initialized it or whatever code will execute in that inner function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;xyz();  // output - xyz is calling...
console.log(xyz)  // output - function xyz(){...} 
function xyz(){
console.log("xyz is calling...");
}
console.log(xyz); // output - function xyz(){...}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What we learned above, about hoisting that works in global execution scope in two way that is variable and function. We know that each program has two parts variable &amp;amp; functions, that hoisting also work for both as same we explained above.&lt;/p&gt;

&lt;p&gt;Let’s take one example for both part&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WEJ8Tr0H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9f6ui98md1dtntci6hn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WEJ8Tr0H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9f6ui98md1dtntci6hn.jpg" alt="Image description" width="880" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sVVFvj6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0rn5ft4sfd9p0pvm62o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sVVFvj6L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p0rn5ft4sfd9p0pvm62o.jpg" alt="Image description" width="880" height="186"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see, hoisting works for both part in above example,&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/ankitkumarsharma/Java-Script-Start-Journey"&gt;GitHub Source Code&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finally, today we learn about Java Script Hoisting, if you have any query for hoisting part, please comment on below section and I’ll try to resolve your query.&lt;/p&gt;

&lt;p&gt;If you want to learn with me, please follow me on social accounts and also go through my website&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ankitkumarsharma.com/"&gt;https://www.ankitkumarsharma.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also please follow me on &lt;a href="https://github.com/ankitkumarsharma"&gt;GitHub&lt;/a&gt; , &lt;a href="https://twitter.com/ankit_k_sharma"&gt;Twitter&lt;/a&gt; , &lt;a href="https://medium.com/@ankit_k_sharma"&gt;Medium&lt;/a&gt;, and &lt;a href="https://dev.to/ankit_k_sharma"&gt;Dev&lt;/a&gt; for more updates on articles with hands on code queries.&lt;/p&gt;

&lt;p&gt;Thanks, Happy coding life !&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Angular Standalone Component — Future of Angular</title>
      <dc:creator>Ankit Kumar Sharma</dc:creator>
      <pubDate>Thu, 07 Jul 2022 20:28:30 +0000</pubDate>
      <link>https://dev.to/ankit_k_sharma/angular-standalone-component-future-of-angular-37l2</link>
      <guid>https://dev.to/ankit_k_sharma/angular-standalone-component-future-of-angular-37l2</guid>
      <description>&lt;p&gt;Today, we will discuss about the future of &lt;code&gt;Angular&lt;/code&gt;, that is --standalone. It refers to components, directives, or pipes that can be used independently of &lt;code&gt;NgModule&lt;/code&gt;.&lt;br&gt;
Let’s create an application without &lt;code&gt;NgModule&lt;/code&gt;.&lt;br&gt;
First we need to install/update our angular-cli, then check version via cli ng version, then create your first project without &lt;code&gt;NgModule&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can create below components without &lt;code&gt;NgModule&lt;/code&gt; part&lt;br&gt;
&lt;strong&gt;Standalone Components&lt;br&gt;
Standalone Directives&lt;br&gt;
Standalone Pipes&lt;/strong&gt;&lt;br&gt;
You can also use lazy load standalone component&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0d4nqfrpj1monr80rqo9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0d4nqfrpj1monr80rqo9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is standalone component ?
&lt;/h2&gt;

&lt;p&gt;Before Angular 14, each component is declared in any of module part, whatever it is &lt;code&gt;appModule&lt;/code&gt; or any other module, but without creating module or declared in any other module, we couldn’t use of any component.&lt;br&gt;
So after release v14, new feature added on this version that is we can use component as without declare in any module, that is called &lt;code&gt;standalone&lt;/code&gt; component.&lt;br&gt;
A component based arictecture with game changer for development as in &lt;code&gt;NgModule&lt;/code&gt; part.&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating standalone component
&lt;/h2&gt;

&lt;p&gt;After create new project, you can create new standalone component by using cli command &lt;code&gt;ng g c &amp;lt;componentName&amp;gt; –-standalone&lt;/code&gt;, after run this command, standalone component will be added on your project.&lt;br&gt;
I am creating one component &lt;code&gt;ng g c home --standalone&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Component, OnInit } from '@angular/core';
 import { CommonModule } from '@angular/common';
@Component({
   selector: 'app-home',
   standalone: true,
   imports: [CommonModule],
   templateUrl: './home.component.html',
   styleUrls: ['./home.component.scss']
 })
 export class HomeComponent implements OnInit {
constructor() { }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1a6b77zdji5jqbo9v5ta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1a6b77zdji5jqbo9v5ta.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Import other useful dependencies as per your requirement
&lt;/h2&gt;

&lt;p&gt;After create your component, you can use and add more things like pipe or any other directives/modules and use of it.&lt;br&gt;
Like, I just import shared module and will use header component on this component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { SharedModule } from './../shared/shared.module';
 import { Component, OnInit } from '@angular/core';
 import { CommonModule } from '@angular/common';
@Component({
   selector: 'app-home',
   standalone: true,
   imports: [CommonModule, SharedModule],
   templateUrl: './home.component.html',
   styleUrls: ['./home.component.scss']
 })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bootstrapping Standalone Component
&lt;/h2&gt;

&lt;p&gt;After release Angular 14, it allow you that you can play to whole application with standalone component by bootstraping that component.&lt;br&gt;
First, you have to go &lt;code&gt;main.ts&lt;/code&gt; file&lt;br&gt;
Replace your standalone component by &lt;code&gt;appModule&lt;/code&gt; like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err =&amp;gt; console.error(err));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;replace this code with below code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bootstrapApplication(HomeComponent).catch(err =&amp;gt; console.error(err));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After changed in &lt;code&gt;main.ts&lt;/code&gt;, now you have to change in &lt;code&gt;index.html&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;app-root&amp;gt;&amp;lt;/app-root&amp;gt;
 &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;replace this code with below code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;app-home&amp;gt;&amp;lt;/app-home&amp;gt;  &amp;lt;!--your standalone component--&amp;gt;
 &amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/ankitkumarsharma/tech-blogs/tree/master/angular-standalone" rel="noopener noreferrer"&gt;Github Source Code&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, Finally we learn about standalone component , how we can use and bootstrap in our application.&lt;/p&gt;

&lt;p&gt;For more about it, will learn on next blog .&lt;/p&gt;

&lt;p&gt;If you want to learn with me, please follow me on social accounts and also go through my website&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.ankitkumarsharma.com/" rel="noopener noreferrer"&gt;https://www.ankitkumarsharma.com/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Also please follow me on &lt;strong&gt;&lt;a href="https://github.com/ankitkumarsharma" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/strong&gt; , &lt;strong&gt;&lt;a href="https://twitter.com/ankit_k_sharma" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;&lt;/strong&gt; , &lt;strong&gt;&lt;a href="https://medium.com/@ankit_k_sharma" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;&lt;/strong&gt;, and &lt;strong&gt;&lt;a href="https://dev.to/ankit_k_sharma"&gt;Dev&lt;/a&gt;&lt;/strong&gt; for more updates on articles with hands on code queries.&lt;/p&gt;

&lt;p&gt;Thanks, Happy coding life !&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>angular</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Conducted a free webinar on Angular Essentials for Corporate Folks</title>
      <dc:creator>Ankit Kumar Sharma</dc:creator>
      <pubDate>Thu, 26 May 2022 17:45:54 +0000</pubDate>
      <link>https://dev.to/ankit_k_sharma/conducted-a-free-webinar-on-angular-essentials-for-corporate-folks-1ppp</link>
      <guid>https://dev.to/ankit_k_sharma/conducted-a-free-webinar-on-angular-essentials-for-corporate-folks-1ppp</guid>
      <description>&lt;h2&gt;
  
  
  I give a free webinar on Angular Essentials, that covered all basic topics from angular, and by this they learned angular and cleared about these below questions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;what is Angular?&lt;/li&gt;
&lt;li&gt;How we can start work on Angular?&lt;/li&gt;
&lt;li&gt;How is career path in Angular?&lt;/li&gt;
&lt;li&gt;Jobs in Angular.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Tj6wOwTK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmskgplo3nxljorck9x1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Tj6wOwTK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nmskgplo3nxljorck9x1.png" alt="Image description" width="880" height="495"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this webinar, folks learned about the following things:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What is Angular&lt;br&gt;
Angular/NodeJS/ VS Code Installation&lt;br&gt;
What is an API&lt;br&gt;
What is a package.json&lt;br&gt;
What is npm&lt;br&gt;
What is git&lt;br&gt;
Installing Angular CLI&lt;br&gt;
Creating the first Angular application&lt;br&gt;
Modules &amp;amp; Component in Angular &lt;br&gt;
Data Binding in Angular&lt;br&gt;
Directives (like *ngFor, *ngIf) in Angular&lt;br&gt;
Pipes in Angular&lt;br&gt;
Basic Routing&lt;br&gt;
Creating basic service&lt;br&gt;
API Integration for GET/POST Operations&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  All folks learned and enjoyed with totally coding part.
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5hw-3NJ2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6e26z30etf5fu45ow7k.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5hw-3NJ2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h6e26z30etf5fu45ow7k.jpeg" alt="Image description" width="880" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to learn with me, please follow me on social accounts and also go through my website&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ankitkumarsharma.com/"&gt;https://www.ankitkumarsharma.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also please follow me on &lt;a href="https://github.com/ankitkumarsharma"&gt;GitHub&lt;/a&gt; , &lt;a href="https://twitter.com/ankit_k_sharma"&gt;Twitter&lt;/a&gt; , &lt;a href="https://medium.com/@ankit_k_sharma"&gt;Medium&lt;/a&gt;, and &lt;a href="https://dev.to/ankit_k_sharma"&gt;Dev&lt;/a&gt; for more updates on articles with hands on code queries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>angular</category>
    </item>
    <item>
      <title>How to use multiple Environment Variables in Angular</title>
      <dc:creator>Ankit Kumar Sharma</dc:creator>
      <pubDate>Sat, 07 May 2022 15:35:30 +0000</pubDate>
      <link>https://dev.to/ankit_k_sharma/how-to-use-multiple-environment-variables-in-angular-2bm7</link>
      <guid>https://dev.to/ankit_k_sharma/how-to-use-multiple-environment-variables-in-angular-2bm7</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TzQGLA4x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtlfwn7xfe7n64e26ljf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TzQGLA4x--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtlfwn7xfe7n64e26ljf.jpg" alt="Image description" width="880" height="351"&gt;&lt;/a&gt;&lt;br&gt;
In this article, we will learn about different Environment Variables in different files.&lt;/p&gt;

&lt;p&gt;First, when we create any angular application, so by default it have two environment files, which one is for dev, and another one is for prod.&lt;br&gt;
But if we need to create more multiple environment files like &lt;strong&gt;QA&lt;/strong&gt;, &lt;strong&gt;UAT&lt;/strong&gt;, &lt;strong&gt;PROD&lt;/strong&gt;, &lt;strong&gt;DEV&lt;/strong&gt; etc and all files, we have different constant variables for API and other values.&lt;/p&gt;
&lt;h2&gt;
  
  
  Add more custom environment files with different values
&lt;/h2&gt;

&lt;p&gt;For our different requirement, we have to create different files under environment folder like qa, uat, xyz etc.&lt;br&gt;
we can add values as per our requirement.&lt;/p&gt;

&lt;p&gt;I have created 3 environment files as per different requirement (dummy). &lt;em&gt;You can create as per your requirement&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;environment.qa.ts // for QA Testing Part
environment.uat.ts // for UAT Testing Part
environment.xyz.ts // for client demo part

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tavo796X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsiqeh085a6gvurnp3t6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tavo796X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bsiqeh085a6gvurnp3t6.jpg" alt="Image description" width="880" height="478"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// we generated this file for UAT Testing Part
export const environment = {
  production: true,
  environmentName: 'UAT',
  apiUrl: 'uat.abc.com',
  paginationSize:'20',
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Update Config Part on anjular.json file
&lt;/h2&gt;

&lt;p&gt;In each angular project, there is a file &lt;strong&gt;angular.json&lt;/strong&gt; that have config part and setup of project related information, so we have to add new environment files for use in our project&lt;br&gt;
We can add new part under &lt;strong&gt;&lt;em&gt;projects/architect/build/configurations&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---yhYYna0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3t59kbozaxq0glklvlv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---yhYYna0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y3t59kbozaxq0glklvlv.jpg" alt="Image description" width="880" height="482"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"uat": {
   "fileReplacements": [
  {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.uat.ts"
  }
   ],
   "outputHashing": "all"
 },
 "qa": {
   "fileReplacements": [
  {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.qa.ts"
  }
   ],
   "outputHashing": "all"
 },
 "xyz": {
   "fileReplacements": [
  {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.xyz.ts"
  }
   ],
   "outputHashing": "all"
 },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Ready Build for a custom environment
&lt;/h2&gt;

&lt;p&gt;when your configuration part is ready, then you can create build for your respective environment as per your requirement by a flag &lt;strong&gt;— configuration&lt;/strong&gt; run with ng build command.&lt;br&gt;
for example.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ng build --configuration uat&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/ankitkumarsharma/environment-variable"&gt;GitHub Source Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;when build is ready, then you can publish your files as per respective environment.&lt;/p&gt;

&lt;p&gt;Please give your respectve feedback, that will be helpfull for improve my article quality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ankitkumarsharma.com/"&gt;https://www.ankitkumarsharma.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also please follow me on &lt;a href="https://github.com/ankitkumarsharma"&gt;GitHub&lt;/a&gt; , &lt;a href="https://twitter.com/ankit_k_sharma"&gt;Twitter&lt;/a&gt; , &lt;a href="https://medium.com/@ankit_k_sharma"&gt;Medium&lt;/a&gt;, and &lt;a href="https://dev.to/ankit_k_sharma"&gt;Dev&lt;/a&gt; for more updates on articles with hands on code queries.&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>angular</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Component Interaction in Angular</title>
      <dc:creator>Ankit Kumar Sharma</dc:creator>
      <pubDate>Fri, 15 Apr 2022 14:04:14 +0000</pubDate>
      <link>https://dev.to/ankit_k_sharma/component-interaction-in-angular-5cn2</link>
      <guid>https://dev.to/ankit_k_sharma/component-interaction-in-angular-5cn2</guid>
      <description>&lt;p&gt;Hello guys, I am writing my first blog on Angular. As we know, Angular is a module-component based frontend-end framework.&lt;/p&gt;

&lt;p&gt;By this tutorial, you can learn, how we can share data between component in Angular in different way. I am providing those way then you can understand easily.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Communication through Parent Component to Child Component (Input Decorator)&lt;/li&gt;
&lt;li&gt;Communication through Child Component to Parent Component (ViewChild Decorator)&lt;/li&gt;
&lt;li&gt;Communication through Child Component to Parent Component (Output/EventEmitter Decorator)&lt;/li&gt;
&lt;li&gt;Communication through Sibling Components (As a service)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Communication through Parent Component to Child Component (Input Decorator)
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
Most common way to introduce data share via Input decorator that allow data to passed via template with data binding. Here, data list sharing via parent component to child component. I am showing a data list via this way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;parent.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-parent',
  template: `&amp;lt;app-child [data]="dataList"&amp;gt;&amp;lt;/app-child&amp;gt;`,
  styleUrls: ['./parent.component.scss']
})
export class ParentComponent implements OnInit {
  public dataList: ParentDataList[] = PARENT_DATA_LIST;
  constructor() { }
  ngOnInit(): void {
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;child.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-child',
  template: `&amp;lt;div class="table-responsive"&amp;gt;
  &amp;lt;table class="table"&amp;gt;
    &amp;lt;tr&amp;gt;
      &amp;lt;th&amp;gt;Id&amp;lt;/th&amp;gt;
      &amp;lt;th&amp;gt;User ID&amp;lt;/th&amp;gt;
      &amp;lt;th&amp;gt;Title&amp;lt;/th&amp;gt;
      &amp;lt;th&amp;gt;Body&amp;lt;/th&amp;gt;
    &amp;lt;/tr&amp;gt;
    &amp;lt;tr *ngFor="let item of data"&amp;gt;
      &amp;lt;td&amp;gt;{{item.id}}&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;{{item.userId}}&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;{{item.title}}&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;{{item.body}}&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/div&amp;gt;`,
  styleUrls: ['./child.component.scss']
})
export class ChildComponent implements OnInit {
  @Input() data!: ParentDataList[];
  constructor() { }
  ngOnInit(): void {
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Communication through Child Component to Parent Component (ViewChild Decorator)
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
ViewChild decorator , we can passed data via child component to parent component. When we inject ViewChild into parent component, then it give access to parent with it’s variables and functions, then we can use as per our requirement. I am trying to add list via this way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;parent.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-parent',
  template: `&amp;lt;button class="primary-btn" (click)="addList()"&amp;gt;Add List&amp;lt;/button&amp;gt;
&amp;lt;app-child&amp;gt;&amp;lt;/app-child&amp;gt;`,
  styleUrls: ['./parent.component.scss']
})
export class ParentComponent implements OnInit, AfterViewInit {
  @ViewChild(ChildComponent) child!: ChildComponent;
  constructor() { }
  ngOnInit(): void {
  }
  addList(){
     let obj = {
        id: 1,
        userId: 123,
        title: 'ankit',
        body:'every thing mcm complrter'
      }
     this.child.arrList = [...this.child.arrList, obj];
  }
  ngAfterViewInit(){
    this.child.showList(true);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;child.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-child',
  template: `&amp;lt;table *ngIf="collapseList" class="table"&amp;gt;
  &amp;lt;tr *ngFor="let item of arrList;let i=index;"&amp;gt;
    &amp;lt;td&amp;gt;{{item.id}}{{i}}&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;{{item.userId}}{{i}}&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;{{item.title}}{{i}}&amp;lt;/td&amp;gt;
    &amp;lt;td&amp;gt;{{item.body}}{{i}}&amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;`,
  styleUrls: ['./child.component.scss']
})
export class ChildComponent implements OnInit {
  public collapseList!: boolean
  public arrList:DataList[] = [];
  constructor() { }
  ngOnInit(): void {}
  showList(value:any){
    this.collapseList = value;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Communication through Child Component to Parent Component (Output/EventEmitter Decorator)
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;Output decorator, This is the another way to share data from child component to parent component via event emitter, as in emit data from the child component to parent component. It works like a event binding in angular. We can share data on any type of event occur via this way like on change, on click etc. I create a small addition/multiply/subtraction/divide functionality by this way.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;parent.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-parent',
  template: `&amp;lt;div class="row"&amp;gt;
  &amp;lt;div class="col-md-2"&amp;gt;
    &amp;lt;input #text1 (change)="text1Data(text1.value)" type="number" value="0" class="form-control"&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class="col-1"&amp;gt;
    &amp;lt;h2 class="ak-title-lg"&amp;gt;{{optSymbal}}&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class="col-md-2"&amp;gt;
    &amp;lt;input #text2 (change)="text2Data(text2.value)" type="number" value="0" class="form-control"&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class="col-md-1"&amp;gt;
    &amp;lt;p class="ak-title"&amp;gt;=&amp;lt;/p&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class="col-md-3"&amp;gt;
    &amp;lt;input type="text" class="form-control" [value]="result" disabled&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;app-child (btnClick)="operationClick($event)"&amp;gt;&amp;lt;/app-child&amp;gt;`,
  styleUrls: ['./parent.component.scss']
})
export class ParentComponent implements OnInit {
  public inputValue1: number = 0;
  public inputValue2: number = 0;
  public result: number = 0;
  public optSymbal:any;
  constructor() {}
  text2Data(value: number) {
    this.inputValue2 = value;
  }
  text1Data(value: number) {
    this.inputValue1 = value;
  }
  ngOnInit(): void {}
  operationClick($event: any) {
    this.optSymbal = $event;
    switch ($event) {
      case OPERATION.addition:
        this.result = this.inputValue1 + this.inputValue2;
        break;
      case OPERATION.subtract:
        this.result = this.inputValue1 - this.inputValue2;
        break;
      case OPERATION.multiply:
        this.result = this.inputValue1 * this.inputValue2;
        break;
      case OPERATION.division:
        this.result = this.inputValue1 / this.inputValue2;
        break;
      default:
        break;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;child.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-child',
  template: `&amp;lt;table class="table"&amp;gt;
  &amp;lt;tr class="row"&amp;gt;
    &amp;lt;td class="col-md-3 col-6" *ngFor="let item of btnArr;let i=index;"&amp;gt;
      &amp;lt;button class="primary-btn" (click)="changeData(item.opt)"&amp;gt;{{item.title}}&amp;lt;/button&amp;gt;
    &amp;lt;/td&amp;gt;
  &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;`,
  styleUrls: ['./child.component.scss']
})
export class ChildComponent implements OnInit {
  @Output() btnClick:EventEmitter&amp;lt;any&amp;gt; = new EventEmitter();
  btnArr = BTN_OPERATION_ARR;
  constructor() { }
  ngOnInit(): void {
  }
  changeData(value:string){
    this.btnClick.emit(value);
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Communication through Sibling Components (As a service)
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;p&gt;In this way, we can use multiple scenario like via RxJS, get/set methods and more ways. I am explaining here via getter/setter methods, with RxJS BehaviorSubject will discuss in next blog. So I am trying to show and hide a data via service method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;sibling1.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-sibling1',
  template: `&amp;lt;p&amp;gt;sibling1 works!&amp;lt;/p&amp;gt;
&amp;lt;h2 class="ak-title"&amp;gt;This is a &amp;lt;span [ngClass]="{'true': show_flag, 'false': !show_flag}"&amp;gt;{{show_flag ? 'True':'False'}}&amp;lt;/span&amp;gt; condition&amp;lt;/h2&amp;gt;
&amp;lt;a class="primary-btn" routerLink="child"&amp;gt;Go to child &amp;gt;&amp;gt;&amp;gt;&amp;lt;/a&amp;gt;`,
  styleUrls: ['./sibling1.component.scss']
})
export class Sibling1Component implements OnInit {
  show_flag:any;
  constructor(private dataService: DataService) { }
  ngOnInit() {
    this.getData()
  }
  getData(){
    this.show_flag = this.dataService.getData();
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;sibling2.component.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'app-sibling2',
  template: `&amp;lt;button class="primary-btn" routerLink="/"&amp;gt;Back&amp;lt;/button&amp;gt;
&amp;lt;app-contact [data]="contactData"&amp;gt;&amp;lt;/app-contact&amp;gt;
&amp;lt;p&amp;gt;child works!&amp;lt;/p&amp;gt;
&amp;lt;button class="secondary-btn" (click)="changeCondition()"&amp;gt;Change Condition&amp;lt;/button&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;
&amp;lt;a class="primary-btn" routerLink="/service-based"&amp;gt; &amp;lt;&amp;lt;&amp;lt; Go to Parent&amp;lt;/a&amp;gt;`,
  styleUrls: ['./sibling2.component.scss']
})
export class Sibling2Component implements OnInit {
  contactData = CONTACT_HEADER;
  constructor(private dataService: DataService) { }
  changeValue:any;
  ngOnInit() {
    this.changeValue = this.dataService.getData();
  }
  changeCondition(){
    this.changeValue = !this.changeValue;
    this.dataService.setData(this.changeValue);
    alert('Done, Now click on Go to Parent');
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;data.service.ts&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Injectable({
  providedIn: 'root'
})
export class DataService {
  public isEnable: boolean = false;
  constructor() { }
  // we are communication data between two component via service -- getter/setter method
  //-----------------------------------------------------------
  // setter method
  setData(data:any){
    this.isEnable = data;
  }
  // getter method
  getData(){
    return this.isEnable;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have any query or doubts, please quick add comment, will try to resolve your query.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/ankitkumarsharma/angular-component-interaction"&gt;GitHub Source Code&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;&lt;a href="https://ankitkumarsharma.github.io/angular-component-interaction/#/home"&gt;Demo&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.ankitkumarsharma.com/"&gt;https://www.ankitkumarsharma.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also please follow me on &lt;a href="https://github.com/ankitkumarsharma"&gt;GitHub&lt;/a&gt; , &lt;a href="https://twitter.com/ankit_k_sharma"&gt;Twitter&lt;/a&gt; , &lt;a href="https://medium.com/@ankit_k_sharma"&gt;Medium&lt;/a&gt;, and &lt;a href="https://dev.to/ankit_k_sharma"&gt;Dev&lt;/a&gt; for more updates on articles with hands on code queries.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>angular</category>
    </item>
  </channel>
</rss>
