<?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: Deepa Chaurasia</title>
    <description>The latest articles on DEV Community by Deepa Chaurasia (@deepachaurasia1).</description>
    <link>https://dev.to/deepachaurasia1</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%2F721888%2F02955ba3-e67d-4e29-b481-18e8a3dca482.jpg</url>
      <title>DEV Community: Deepa Chaurasia</title>
      <link>https://dev.to/deepachaurasia1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deepachaurasia1"/>
    <language>en</language>
    <item>
      <title>Angular Interview Coding Question</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Fri, 24 Nov 2023 09:29:29 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/angular-interview-coding-question-1gok</link>
      <guid>https://dev.to/deepachaurasia1/angular-interview-coding-question-1gok</guid>
      <description>&lt;h2&gt;
  
  
  How to share data between sibling components in Angular?
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Let's say you have a component called First. Inside first component you have a button named increment.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There's another component second , &lt;strong&gt;inside this you have a variable named count=0 .&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now what interviewer wants &lt;strong&gt;if you click on increment button in first component , the count variable must increment in second component and reflect the same&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How you will achieve it???
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'zone.js/dist/zone';
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { bootstrapApplication } from '@angular/platform-browser';
import { AppService } from './app.service'

@Component({
  selector: 'my-first',
  template: `
    &amp;lt;h1&amp;gt;First&amp;lt;/h1&amp;gt;
    &amp;lt;button&amp;gt;Increment&amp;lt;/button&amp;gt;
  `,
  standalone: true,
  imports: [CommonModule],
})
export class First {
  name = 'Angular';
}

@Component({
  selector: 'my-second',
  template: `
    &amp;lt;h1&amp;gt;Second&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;{{count}}&amp;lt;/h2&amp;gt;
  `,
  standalone: true,
  imports: [CommonModule],
})
export class Second {
  count: number = 0;
  name = 'Angular';
}



@Component({
  selector: 'my-app',
  standalone: true,
  imports: [First, Second, CommonModule],
  providers: [AppService],
  template: `
    &amp;lt;h1&amp;gt;Hello from {{ name }}!&amp;lt;/h1&amp;gt;
    &amp;lt;a target="_blank" href="https://angular.io/start"&amp;gt;
      Learn more about Angular
    &amp;lt;/a&amp;gt;
    &amp;lt;my-first&amp;gt;&amp;lt;/my-first&amp;gt;
    &amp;lt;my-second&amp;gt;&amp;lt;/my-second&amp;gt;
  `,
})
export class App {
  name = 'Angular';

  constructor(private appService: AppService) {
      console.log(this.appService.getData())
  }
}


bootstrapApplication(App);

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

&lt;/div&gt;



&lt;p&gt;Here's the code .&lt;br&gt;
Link to Question -&lt;a href="https://stackblitz.com/edit/stackblitz-starters-bxdzcr?file=src%2Fmain.ts"&gt;https://stackblitz.com/edit/stackblitz-starters-bxdzcr?file=src%2Fmain.ts&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Answer :&lt;/p&gt;

&lt;p&gt;There could be multiple approaches to achieve the same . But what i find easiest is through services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Services in angular is used to establish a communication between the components who don't have parent child relationship and are completely different.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here in above interview question &lt;strong&gt;first and second both are sibling components&lt;/strong&gt;. Therefore you will use service here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First you will &lt;strong&gt;create a service (i.e app.service.ts)&lt;/strong&gt; here.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Second you will &lt;strong&gt;create two methods inside it, one is to get updated data (i.e getData())&lt;/strong&gt; , then the increment the count number that will be shared between two sibling component. We will create &lt;strong&gt;incrementData()&lt;/strong&gt; method for this.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now you will have to &lt;strong&gt;create a subject count&lt;/strong&gt; , that you are going to subscribe to get updated value every time increment button is clicked.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Subjects are the kind of observable that gives you updated value consistently after every change. You can call next method to get updated value.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;_That's how your code should look like _&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';

@Injectable()
export class AppService {
  constructor() {}

  count = new Subject&amp;lt;number&amp;gt;();

  incrementData(count: number) {
    this.count.next(count);
  }

  getData() {
    return this.count;
  }
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now in first component you have to create a method that will call on every click of increment button.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Remember &lt;strong&gt;first step is initialise service inside constructor and then use it later to access service method&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: 'my-first',
  template: `
    &amp;lt;h1&amp;gt;First&amp;lt;/h1&amp;gt;
    &amp;lt;button (click)="incrementData()"&amp;gt;Increment&amp;lt;/button&amp;gt;
  `,
  standalone: true,
  imports: [CommonModule],
})
export class First {
  name = 'Angular';
  count: number = 0;

  constructor(private appService: AppService) {}

  incrementData() {
    this.appService.incrementData(this.count++);
  }
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now in Second Component &lt;strong&gt;you have subscribe to the subject created in service and update value&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component({
  selector: 'my-second',
  template: `
    &amp;lt;h1&amp;gt;Second&amp;lt;/h1&amp;gt;
    &amp;lt;h2&amp;gt;{{count}}&amp;lt;/h2&amp;gt;
  `,
  standalone: true,
  imports: [CommonModule],
})
export class Second {
  constructor(private appService: AppService) {
    this.appService.getData().subscribe((data) =&amp;gt; {
      console.log(data);
      this.count = data;
    });
  }
  count: number = 0;

  name = 'Angular';
}

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

&lt;/div&gt;



&lt;p&gt;That's how you will do it . &lt;/p&gt;

&lt;p&gt;Full code for answer is here :&lt;a href="https://stackblitz.com/edit/stackblitz-starters-gv2eui?file=src%2Fmain.ts"&gt;https://stackblitz.com/edit/stackblitz-starters-gv2eui?file=src%2Fmain.ts&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me know if you have more ways to do it in comments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for reading, do share if it helps you&lt;/em&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>How child component communicate with parent in React???</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Wed, 22 Nov 2023 08:50:06 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/how-to-use-method-as-props-in-react-lnm</link>
      <guid>https://dev.to/deepachaurasia1/how-to-use-method-as-props-in-react-lnm</guid>
      <description>&lt;p&gt;&lt;em&gt;In that case we used reference to method as props to child component&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let's create a Parent component first&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Here you have to notice few points&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First you will create a &lt;strong&gt;parent component&lt;/strong&gt; with constructor &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Within the constructor you &lt;strong&gt;set a state called parentName with value Parent&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next define a method &lt;strong&gt;greetParent()&lt;/strong&gt; which alert hello with the parentName initialized.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In the constructor you will assign this.greetParent to &lt;strong&gt;this.greetparent.bind(this)&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now you will create child.component.ts&lt;/p&gt;

&lt;p&gt;We are not using state here therefore we can use a simpler component here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Here you will just add a button &lt;strong&gt;"Greet Parent"&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Back in parent component , you will include child component in render method .&lt;strong&gt;Make sure to import component at top.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;You will render &lt;strong&gt;parent component&lt;/strong&gt; in app.js&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;em&gt;After running you will see&lt;/em&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;But nothing will happen if you click the button.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In ParentComponent render method you are going to add child attribute named &lt;strong&gt;greetHandler&lt;/strong&gt;. And to this we assign &lt;strong&gt;greetParent()&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;In child component on click of button we call &lt;strong&gt;props.greetHandler&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;When you click button you will see alert like this&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;em&gt;Now we will see _how to pass a parameter when calling a parent method from child component&lt;/em&gt; and this is where an arrow function in the return statement is really useful_&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Array function syntax is the simplest way to pass parameters from child component to parent component.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is how you will change your child component to achieve this&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;In parent component you will receive props like this and &lt;strong&gt;change alert method&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;&lt;em&gt;After this you will see the message like this while clicking on send button.&lt;/em&gt;&lt;/p&gt;

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

</description>
      <category>reactnative</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>What is Change Detection in Angular?</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Sat, 27 May 2023 13:28:54 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/what-is-change-detection-in-angular-1jme</link>
      <guid>https://dev.to/deepachaurasia1/what-is-change-detection-in-angular-1jme</guid>
      <description>&lt;p&gt;Change detection is *&lt;em&gt;detecting changes in any component *&lt;/em&gt; of your app and re-render view, so it displays updated value to end users.&lt;/p&gt;

&lt;p&gt;Different events on which change occurs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data received from network requests or component events.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mouse clicks,scrolling,mouseover,keyboard navigation&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AJAX Calls&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use of timer function such as setTimeout() or setInterval().&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How does Change detection work??
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Whenever something triggers a change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To detect and update DOM with changed data,the framework provides its own change detection detector for each component.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The change detector make sure data model and DOM are in sync.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When Angular change detection detects the triggered change and run change detection to all component tree from top to bottom.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Angular Change Detection strategies
&lt;/h2&gt;

&lt;p&gt;There are two strategies basically in angular:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Default Change Detection Strategy&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;OnPush Change Detection Strategy&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Default Change Detection Strategy
&lt;/h2&gt;

&lt;p&gt;If &lt;strong&gt;Angular Change Detector&lt;/strong&gt; is set to default then for any change in any model property, Angular will run change detection traversing component tree to update DOM.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Change Detector Ref&lt;/strong&gt; class provides few built in methods , we can use to manipulate change detection tree.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;markForCheck()&lt;/strong&gt; - marks that it changed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;detach()&lt;/strong&gt; - exclude view from change detection tree&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;detect Changes()&lt;/strong&gt; - check view and its child component&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;checkNoChanges()&lt;/strong&gt; -check view and it's child ,throw error if changes detected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;reattach()&lt;/strong&gt; - reattach a view that was previously detached&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Angular OnPush Change Detection Strategy
&lt;/h2&gt;

&lt;p&gt;If angular change detector is set to &lt;strong&gt;onPush&lt;/strong&gt; then Angular will run change detector only when new reference is being passed to component.&lt;/p&gt;

&lt;p&gt;If observable is passed to onPush, then changeDetector must be called manually to update DOM&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unnecessary check in child not performed if parent element updating values which are not passed @Input&lt;/p&gt;

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

&lt;p&gt;Here we have changed strategy to OnPush&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Hope it help you guys :)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Please like share and subscribe if you like it&lt;/em&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Request and Response Interceptors in JS</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Sat, 27 May 2023 13:27:12 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/request-and-response-interceptors-in-js-1nah</link>
      <guid>https://dev.to/deepachaurasia1/request-and-response-interceptors-in-js-1nah</guid>
      <description>&lt;p&gt;Interceptors work as a wall between client and server.&lt;/p&gt;

&lt;p&gt;Whenever a request is sent from client to server we can do all kind of processing like changing header,or any operation that can be done in interceptor.&lt;/p&gt;

&lt;p&gt;After that interceptor will carry forward the request to the server&lt;/p&gt;

&lt;p&gt;Similarly in response interceptor we can check whether the server is sending right response,will check status code if user is authorized or not and then we can do different type of actions as per our requirement and return back those response to client&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Directive Composition API</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Mon, 15 May 2023 13:02:17 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/directive-composition-api-jf6</link>
      <guid>https://dev.to/deepachaurasia1/directive-composition-api-jf6</guid>
      <description>&lt;p&gt;The directive composition API lets you apply directives to a component's host element from within the component TypeScript class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding directives to a component&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You apply directives to a component by adding a hostDirectives property to a component's decorator. We call such directives host directives.&lt;/p&gt;

&lt;p&gt;In this example, we apply the directive &lt;strong&gt;MenuBehavior&lt;/strong&gt; to the host element of AdminMenu. This works similarly to applying the** MenuBehavior** to the  element in a template.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Component({&lt;br&gt;
  selector: 'admin-menu',&lt;br&gt;
  template: 'admin-menu.html',&lt;br&gt;
  hostDirectives: [MenuBehavior],&lt;br&gt;
})&lt;br&gt;
export class AdminMenu { }&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When the framework renders a component, Angular also creates an instance of each host directive. The directives' host bindings apply to the component's host element. By default, host directive inputs and outputs are not exposed as part of the component's public API. See Including inputs and outputs below for more information.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Angular applies host directives statically at compile time. You cannot dynamically add directives at runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Directives used in hostDirectives must be standalone: true.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Angular ignores the selector of directives applied in the hostDirectives property.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Including inputs and outputs&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you apply hostDirectives to your component, the inputs and outputs from the host directives are not included in your component's API by default. You can explicitly include inputs and outputs in your component's API by expanding the entry in hostDirectives:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Component({&lt;br&gt;
  selector: 'admin-menu',&lt;br&gt;
  template: 'admin-menu.html',&lt;br&gt;
  hostDirectives: [{&lt;br&gt;
    directive: MenuBehavior,&lt;br&gt;
    inputs: ['menuId'],&lt;br&gt;
    outputs: ['menuClosed'],&lt;br&gt;
  }],&lt;br&gt;
})&lt;br&gt;
export class AdminMenu { }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;By explicitly specifying the inputs and outputs, consumers of the component with hostDirective can bind them in a template:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;admin-menu menuId="top-menu" (menuClosed)="logMenuClosed()"&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;you can alias inputs and outputs from hostDirective to customize the API of your component:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;@Component({&lt;br&gt;
  selector: 'admin-menu',&lt;br&gt;
  template: 'admin-menu.html',&lt;br&gt;
  hostDirectives: [{&lt;br&gt;
    directive: MenuBehavior,&lt;br&gt;
    inputs: ['menuId: id'],&lt;br&gt;
    outputs: ['menuClosed: closed'],&lt;br&gt;
  }],&lt;br&gt;
})&lt;br&gt;
export class AdminMenu { }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;admin-menu id="top-menu" (closed)="logMenuClosed()"&amp;gt;&lt;/code&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>Hoisting in JavaScript</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Thu, 16 Mar 2023 18:39:29 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/hoisting-in-javascript-48b8</link>
      <guid>https://dev.to/deepachaurasia1/hoisting-in-javascript-48b8</guid>
      <description>&lt;p&gt;Hoisting simple gives &lt;strong&gt;higher specificity to javascript declarations.&lt;/strong&gt; Thus, it makes the computer read and process declarations first before analyzing other code in program.&lt;/p&gt;

&lt;p&gt;Note: Hosting does not mean JavaScript rearranges or move code above one anothers.&lt;/p&gt;

&lt;p&gt;E.g.&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(name); 
// Uncaught ReferenceError: name is not defined
let name = 'Deepa'; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;variables declared with let and const are hoisted but not initialized with a default value.&lt;/li&gt;
&lt;li&gt;Accessing let or const before it's declared will give: Uncaught ReferenceError: can't access before initialization&lt;/li&gt;
&lt;li&gt;Remember the error message tells variable is initialized somewhere.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Variable hoisting with var
&lt;/h2&gt;

&lt;p&gt;When interpreter hoists a variable declared with var, it initialized its value to undefined, unlike let or const.&lt;br&gt;
E.g.&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(name); // undefined
var name = 'deepa';
console.log(name); // deepa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's analyze this behaviour:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var name;
console.log(name); // undefined
name = 'partha';
console.log(name); // partha
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remember, the first console.log(name) outputs &lt;strong&gt;undefined because name is hoisted&lt;/strong&gt;, and given a default value (not because variable is never declared).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using undefined variable will throw ReferenceError&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(name); // Uncaught ReferenceError: name is not defined&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now let's see if we don't declare var what happens.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;console.log(name); // partha&lt;br&gt;
name = 'partha';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;name = assigning a variable that's not declared is valid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript let us access variable before they're declared.&lt;/strong&gt; This behaviour is an unusual part of javascript and can lead to errors.&lt;/p&gt;

&lt;p&gt;Using variable before it's declaration is not desirable.&lt;/p&gt;
&lt;h2&gt;
  
  
  The temporal Dead Zone
&lt;/h2&gt;

&lt;p&gt;The reason why we get reference error when we try to access let or const before its declaration is &lt;strong&gt;Temperal Dead Zone&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The TDZ starts at beginning of the variables enclosing scope and ends when it is declared.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Accessing variable in TDZ gives ReferenceError&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;E.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    // start of foo's TDZ
    let bar = 'bar';
    console.log(bar); // bar
    console.log(foo); // ReferenceError: Because we're in TDZ
    let foo = 'foo';
    // end of foo's TDZ
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;type of TDZ for let or const: ReferenceError&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;type of TDZ for var: undefined&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Functional Hoisting
&lt;/h2&gt;

&lt;p&gt;Function declarations are hoisted too. Function hoisting allows us to call function before it is declared or defined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
foo(); 
function foo() {
    console.log('foo'); // foo
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: only function declaration are hoisted not function expressions.&lt;/p&gt;

&lt;p&gt;E.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;foo(); // Uncaught TypeError: foo is not a function
var foo = function() {

}

bar(); // Uncaught ReferenceError
let bar = function() {

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Uncaught ReferenceError&lt;/strong&gt;: can't access 'bar' before initialization similarly for const.&lt;/p&gt;

&lt;p&gt;For function that is never declared:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;foo(); // Uncaught ReferenceError: foo is not defined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>programming</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>My Devfest Experince as Speaker </title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Sun, 11 Dec 2022 18:29:01 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/my-devfest-experince-as-speaker-51am</link>
      <guid>https://dev.to/deepachaurasia1/my-devfest-experince-as-speaker-51am</guid>
      <description>&lt;p&gt;Hello everyone , I generally post about angular and tech related stuff only . However what i want to share today is also pretty much about tech event only.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Today I had my first ever Event of DevFest as Speaker &lt;/strong&gt;. &lt;em&gt;What made me write this blog is to share my experience and motivate other tech enthusiast to come forward and become speaker at such events.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Let me count you the reasons why you must be at such events:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;All the attendes present there are genuinely attentive and are willing to learn something new.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You get great vibes from everywhere around&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It's the platform to give back to your community.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It gives you the recognition in the industry as well.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;I have attended the devfest Noida where most of the attendes were student. These students were not just immensly talented but the great audience as well.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F4cenrwy1xwp7crseckid.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F4cenrwy1xwp7crseckid.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I really liked the respect they have for speakers and will to gain more and more knowledge .What i have realised is these students realise importance of knowledge and that's why they are valued everywhere.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What have become pretty common these days is not respecting your teacher.I was pretty impressed with my audience out there&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Apart from that I got the chance to meet amazing tech leaders from big companies. Their insights will be life long lesson for me . Meeting such great personaties and sharing stage with them is a blessing for me .&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F9569b4yifjab94u03x44.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F9569b4yifjab94u03x44.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From my childhood ,I have felt the most confident on stage .You will be shocked to know I am an under confident person in real life . But an over confident person on stage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F0swqr9wmxlqyld7xej4g.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F0swqr9wmxlqyld7xej4g.jpg" alt="Image description" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THIS IS ME ,CONFIDENT ON STAGE :)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I don't know something's really wrong here but that's how it is.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Apart from this the level of efforts volunteers give to make these events a success is just incredible . People were comparing #devfestNoida with international events.Their team work was pretty awesome. We can see what team work can do after these success events&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ffc106g8f2r2zn154niof.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ffc106g8f2r2zn154niof.jpg" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And let me tell you these volunteers were the college students.The organizers were also young but pretty wise at taking decisions and executing the event.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One must always participate at such events as a volunteer,attendee,speaker or Organizer itself because it actually pushes you to develop the qualities you were not aware you had.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>welcome</category>
    </item>
    <item>
      <title>Why Typescript not JS?</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Thu, 01 Dec 2022 16:53:22 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/why-typescript-not-js-20l3</link>
      <guid>https://dev.to/deepachaurasia1/why-typescript-not-js-20l3</guid>
      <description>&lt;p&gt;As a Frontend Developer,this question comes often in our mind whether one should go for typescript or javascript.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;TypeScript is JavaScript with syntax for types.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale.&lt;/p&gt;

&lt;p&gt;TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js or Deno and in your apps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;--&amp;gt;Typescript is superscript of Javascript with extra features.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>angular</category>
      <category>react</category>
    </item>
    <item>
      <title>How to show or hide component on basis of url in Angular.</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Wed, 30 Nov 2022 07:56:58 +0000</pubDate>
      <link>https://dev.to/playfulprogramming-angular/how-to-show-or-hide-component-on-basis-of-url-in-angular-5134</link>
      <guid>https://dev.to/playfulprogramming-angular/how-to-show-or-hide-component-on-basis-of-url-in-angular-5134</guid>
      <description>&lt;p&gt;As a Frontend developer,You come across a situation where you have to show a component only if you navigate to dashboard,or your login component.For rest you must hide.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How are you going to manage all of this in angular??&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Well Angular provides you a various events and properties of router that you can use to track on which router user is currently at.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will be discussing NavigationEnd event of Angular route&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Navigation End??
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An event triggered when a navigation ends successfully.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Use??
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F2harfke7vu10bg8oey8b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F2harfke7vu10bg8oey8b.png" alt=" " width="558" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside constructor you subscribe to router events.&lt;/li&gt;
&lt;li&gt;Then you will check subscribed val is an instance of Navigation End or not .&lt;/li&gt;
&lt;li&gt;If yes then you will use that subscribed value and use value.url to find the url where user has navigated currently and put logic inside.&lt;/li&gt;
&lt;li&gt;At last you will write your logic according to value.url&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the example above I have wrote logic to not show header on login , else on all other components whether dashboard,or any other headers will be visible.&lt;/p&gt;

&lt;p&gt;My app.component.html looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fvan589wvhuw9c8x7p1fw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fvan589wvhuw9c8x7p1fw.png" alt=" " width="800" height="306"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Here you can see I am showing header only if "showHeader" property is true&lt;br&gt;
*&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My app.component.ts looks like this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F2q264gzw0cdz1ko5nefo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F2q264gzw0cdz1ko5nefo.png" alt=" " width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Now If i click on submit button it will route to 'dashboard'&lt;br&gt;
and shows dashboard component.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2F438eks2ytx4ufjtq3ju0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F438eks2ytx4ufjtq3ju0.png" alt=" " width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Therefore header component becomes visible *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ficxw01jtlyokvnlfw5ob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ficxw01jtlyokvnlfw5ob.png" alt=" " width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The working respository for reference &lt;br&gt;
&lt;a href="https://stackblitz.com/edit/angular-ivy-atods7?file=src/app/app.component.ts" rel="noopener noreferrer"&gt;https://stackblitz.com/edit/angular-ivy-atods7?file=src/app/app.component.ts&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Github Link&lt;br&gt;
&lt;a href="https://github.com/deepa314/angular-ivy-atods7.git" rel="noopener noreferrer"&gt;https://github.com/deepa314/angular-ivy-atods7.git&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope it help you guys :)&lt;br&gt;
If you like please like ,share and subscribe&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>angular</category>
    </item>
    <item>
      <title>Closures in Javascript</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Thu, 24 Nov 2022 18:57:07 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/closures-in-javascript-1pl</link>
      <guid>https://dev.to/deepachaurasia1/closures-in-javascript-1pl</guid>
      <description>&lt;p&gt;&lt;strong&gt;A closure is a function combined with references to variables define outside of it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;They enclose the function and variable in its environment.&lt;/p&gt;

&lt;p&gt;Let's say you're having a function greet&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;There's two interesting points to notice here.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The retured function from greet can access the word parameter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The returned function maintain the value of word when greetings is called outside scope of word.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The first point can be explained by lexical Scope&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lexical Scope&lt;/strong&gt;- The returned function can access word before it exists in its outer scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The second point because of closures&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Closure maintains the variable references ,which allows function to access variables outside of their scope.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples of Closures in Javascript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Example 1:&lt;/p&gt;

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

&lt;p&gt;In the example above, the function numberGenerator creates a local “free” variable num (a number) and checkNumber (a function which prints num to the console).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The function checkNumber doesn’t have any local variables of its own — however, it does have access to the variables within the outer function, numberGenerator, because of a closure.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Therefore, it can use the variable num declared in numberGenerator to successfully log it to the console even after numberGenerator has returned.&lt;/p&gt;

&lt;p&gt;Example 2:&lt;br&gt;
In this example we’ll demonstrate that a closure contains any and all local variables that were declared inside the outer enclosing function.&lt;/p&gt;

&lt;p&gt;function sayHello() {&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Notice how the variable hello is defined after the anonymous function — but can still access the hello variable. This is because the hello variable has already been defined in the function “scope” at the time of creation, making it available when the anonymous function is finally executed.&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Possible ways to send data through Routing in angular</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Fri, 18 Nov 2022 18:55:01 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/possible-ways-to-send-data-through-routing-in-angular-5g3n</link>
      <guid>https://dev.to/deepachaurasia1/possible-ways-to-send-data-through-routing-in-angular-5g3n</guid>
      <description>&lt;p&gt;While developing the large-scale applications,You may often came up with the scenarios where you want to send data through routing parameters. I will discuss all possible ways to do the same.&lt;/p&gt;

&lt;h2&gt;
  
  
  NAVIGATION AND ROUTE PARAMS
&lt;/h2&gt;

&lt;p&gt;We can send data through navigation, and most often we use this method .&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to use it??&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: In your routing module, set up your routes with the params you wanna send.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { RoleUserMapComponent } from './role-user-map.component';

const routes: Routes = [
  { path: '', component: RoleUserComponent },
  { path: 'add',component:RoleUserAddComponent },
  { path: 'edit/:userId',component:RoleUserEditComponent },
  { path: 'detail/:userId', component:RoleUserDetailComponent 
];

@NgModule({
 imports: [RouterModule.forRoot(routes, { useHash: true })],
 exports: [RouterModule],
 providers: []
})
export class AppRoutingModule { }


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

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Here in my path, i have attached 'userId' as param ,which will subscribe later from detail and edit component&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 2:Now you will set the navigation either through navigator method or directly through routerLink&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using routerLink&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt; a [routerLink]=”['/edit',userId]”&amp;gt;Edit&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using navigator&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;this.router.navigate(['edit', userId]);&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 3:It's time to subscribe the params we have passed inside our edit/details component
&lt;/li&gt;
&lt;/ul&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 { ActivatedRoute } from '@angular/router';


@Component({
  selector: 'app-role-user-map-edit',
  templateUrl: './role-user-map-edit.component.html',
  styleUrls: ['./role-user-map-edit.component.scss']
})
export class RoleUserMapEditComponent implements OnInit {
private sub: Subscription; 
id:string;

constructor(
    private route: ActivatedRoute
  ) { }

ngOnInit(): void {
     this.sub = this.route.params.subscribe(params =&amp;gt; {
      this.id = params['userId'];
});

 ngOnDestroy(): void {
    this.sub.unsubscribe();
  }


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

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;First you will get activatedRoute by instantiating service inside constructor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Next you will create a private subscription,Remember you have to unsubscribe it in ngOnDestroy to avoid memory leakage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then you subscribe to your activatedRoute and use it .&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Using Query Parameters
&lt;/h2&gt;

&lt;p&gt;Let's say you don't wanna send only userId,You wanna send name and mobileNo as well.While sending multiple parameters you use query parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to use it&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can simply pass queryParams like this
&lt;strong&gt;Using Navigator&lt;/strong&gt;
&lt;code&gt;this.router.navigate( ['edit'], { queryParams: { userId: '1101',mobileNo:931065465}});&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using routerLink&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt; a [routerLink]=”['/edit']”  [queryParams]="{userId: '1101',mobileNo:931065465 }"  &amp;gt;Edit&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here you will simply send your data through queryParams and it will show like &lt;/p&gt;

&lt;p&gt;&lt;a href="http://localhost:4200/userId?userId=1101&amp;amp;mobileNo=9310476536"&gt;http://localhost:4200/userId?userId=1101&amp;amp;mobileNo=9310476536&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that you can simply subscribe it like above except the fact you will use queryParams instead of params this time&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.sub = this.route.queryParams.subscribe(params =&amp;gt; {&lt;br&gt;
      this.id = params['userId'];&lt;br&gt;
      this.mobileNo=params['mobileNo'];&lt;br&gt;
});&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One thing if you are routing to another element further and you want queryParams to be preserved ,queryParamHandling will be used for this&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to use it&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;this.router.navigate( ['details'], { queryParamsHandling:'preserve'});&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;What it will do,let say you need userId in details component, queryParam will be preserved and you can subscribe&lt;/p&gt;

&lt;p&gt;&lt;a href="http://localhost:4200/details?userId=1101&amp;amp;mobileNO=931065465"&gt;http://localhost:4200/details?userId=1101&amp;amp;mobileNO=931065465&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Using Fragments
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;How to use it&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can simply pass fragments just like queryParams &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Using Navigator&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;this.router.navigate( ['edit'], {fragment: { userId: '1101',mobileNo:931065465}});&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using routerLink&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt; a [routerLink]=”['/edit']”  [fragment]="{userId: '1101',mobileNo:931065465 }"  &amp;gt;Edit&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Static Data
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;{ path: 'userId', component: StaticComponent, data :{ userId:'1101', mobileNO:931065465}},&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simply subscribe data in your component just like above&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;  this.route.data.subscribe(data =&amp;gt; {
          this.userInfo=data;
      })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dynamic Data
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Using routerLink&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;a [routerLink]="['/edit']" [state]="{ userId:'1101', mobileNO:931065465}"&amp;gt;Dynamic Data&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using Navigation&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;this.router.navigate( ['edit'], {state: { userId: '1101',mobileNo:931065465}});&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to subscribe?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It's little different from rest,here you have to subscribe in constructor only .It won't work elsewhere&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(private router: Router, private activatedRoute: ActivatedRoute)
 {
console.log(this.router.getCurrentNavigation().extras.state);
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;You can store the state in your local variable and use it anywhere in your program.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I hope it was helpful for you guys .If you liked please share ,like and let me know in comments if any improvement needed. :)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>angular</category>
    </item>
    <item>
      <title>LIFE CYCLE OF ANGULAR COMPONENTS</title>
      <dc:creator>Deepa Chaurasia</dc:creator>
      <pubDate>Wed, 31 Aug 2022 13:12:40 +0000</pubDate>
      <link>https://dev.to/deepachaurasia1/life-cycle-of-angular-components-3445</link>
      <guid>https://dev.to/deepachaurasia1/life-cycle-of-angular-components-3445</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zN5dNstv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmsxbxcqne6d10e7f7yh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zN5dNstv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bmsxbxcqne6d10e7f7yh.png" alt="Image description" width="387" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's discuss one by one&lt;/p&gt;

&lt;h2&gt;
  
  
  Constructor()
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt; It is called on component/directive Instantiation.&lt;/li&gt;
&lt;li&gt; It also allows centralizing the dependency injections.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;YOU MUST AVOID SUBSCRIPTIONS IN CONSTRUCTOR&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ngOnChanges
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It allows to set or reset data-bound input properties.&lt;/li&gt;
&lt;li&gt;You use it if you are using @input decorator in your component.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;h2&gt;
  
  
  ngOnInIt
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It is called once after the first ngOnChanges()&lt;/li&gt;
&lt;li&gt;It allows initializing the component/directive&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Here you can do subscriptions&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ngDoCheck
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  Detect and act upon changes that Angular can't or won't 
detect on its own.&lt;/li&gt;
&lt;li&gt; It is called after every ngOnChanges and just after 
ngOnInit() first run.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ngAfterContentInit
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Respond after Angular projects external content into the 
component's view, or into the view that a directive is in.&lt;/li&gt;
&lt;li&gt; It's called once after ngDoCheck()&lt;/li&gt;
&lt;li&gt; If you use @contentChild to get contentchild ,they are 
initialized here.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  AfterContentCheckedMethod
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Respond after Angular checks the content projected into the 
directive or component.&lt;/li&gt;
&lt;li&gt;It is same as ngDoCheck but for contentChild properties&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  AfterViewInItMethod
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Respond after Angular initializes the component's views and 
child views, or the view that contains the directive.&lt;/li&gt;
&lt;li&gt;It is called only once after first ngAfterContentChecked&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  AfterViewCheckedMethod
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Respond after Angular checks the component's views and 
child views, or the view that contains the directive.&lt;/li&gt;
&lt;li&gt;It is called after the ngAfterViewInit() and every 
subsequent ngAfterContentChecked()&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  OnDestroyMethod
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Cleanup just before Angular destroys the directive or component. Unsubscribe Observables and detach event handlers to avoid memory leaks.&lt;/li&gt;
&lt;li&gt;It is called immediately before Angular destroys the component/directives&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>webdev3</category>
      <category>angular</category>
    </item>
  </channel>
</rss>
