<?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: Mini Bhati</title>
    <description>The latest articles on DEV Community by Mini Bhati (@devminibhati).</description>
    <link>https://dev.to/devminibhati</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%2F716958%2Fe833371f-7cd7-44c2-b55d-5b6c4a21dc27.jpeg</url>
      <title>DEV Community: Mini Bhati</title>
      <link>https://dev.to/devminibhati</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devminibhati"/>
    <language>en</language>
    <item>
      <title>How to respond to input changes reactively in the child component</title>
      <dc:creator>Mini Bhati</dc:creator>
      <pubDate>Mon, 15 Aug 2022 06:15:59 +0000</pubDate>
      <link>https://dev.to/devminibhati/how-to-respond-to-input-changes-reactively-in-the-child-component-28n7</link>
      <guid>https://dev.to/devminibhati/how-to-respond-to-input-changes-reactively-in-the-child-component-28n7</guid>
      <description>&lt;p&gt;Component interaction can work in one of the following three ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ngOnChanges()&lt;/code&gt; lifecycle hooks&lt;/li&gt;
&lt;li&gt;Setters on the &lt;code&gt;@Input()&lt;/code&gt; property&lt;/li&gt;
&lt;li&gt;Services&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your component is a presentational component and interacts only with the &lt;code&gt;@Input()&lt;/code&gt; and &lt;code&gt;@Output()&lt;/code&gt; properties, then using **&lt;em&gt;setters is the most reactive way&lt;/em&gt; **of interacting with the child component&lt;/p&gt;

&lt;p&gt;Let's understand how!&lt;/p&gt;

&lt;h2&gt;
  
  
  Parent Child Component Interaction
&lt;/h2&gt;

&lt;p&gt;Parent component passes value to the child component with the following syntax where userValue is an &lt;a href="https://angular.io/api/core/Input"&gt;@Input()&lt;/a&gt; property in the child component&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;child-component [userValue]="userValue"&amp;gt;&amp;lt;/child-component&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export class ChildComponent {
  @Input() userValue;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setters on the &lt;code&gt;@Input()&lt;/code&gt; property
&lt;/h2&gt;

&lt;p&gt;Setters on the &lt;a href="https://angular.io/api/core/Input"&gt;@Input()&lt;/a&gt; property runs some additional logic whenever the input changes.&lt;br&gt;
So, instead of defining userValue, we define a function on the userValue property which executes whenever input changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export class ChildComponent {
  status = false;
  @Input() set userValue(value: string) {
      this.status = true;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are called property accessor methods which executes on setting/getting values. Add a &lt;code&gt;set&lt;/code&gt; keyword before a property to make a setter.&lt;/p&gt;




&lt;h2&gt;
  
  
  Thanks for reading!
&lt;/h2&gt;

&lt;p&gt;Please feel free to reach out on &lt;a href="https://twitter.com/devminibhati"&gt;Twitter&lt;/a&gt; or &lt;a href="https://www.linkedin.com/in/minibhati93/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>List of Angular CLI commands we use daily</title>
      <dc:creator>Mini Bhati</dc:creator>
      <pubDate>Fri, 07 Jan 2022 12:20:10 +0000</pubDate>
      <link>https://dev.to/devminibhati/list-of-angular-cli-commands-we-use-daily-1jab</link>
      <guid>https://dev.to/devminibhati/list-of-angular-cli-commands-we-use-daily-1jab</guid>
      <description>&lt;p&gt;In this post, I am consolidating all the commonly used Angular CLI commands which every Angular developer uses frequently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a NEW angular project
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng new &amp;lt;project-name&amp;gt;

ng n &amp;lt;project-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Add NPM packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng add &amp;lt;npm-package&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Run the Angular project
&lt;/h3&gt;

&lt;p&gt;The application is run on port 4200 by default. You can specify the port in the following command using &lt;em&gt;--port&lt;/em&gt; flag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Generate new Schematics
&lt;/h3&gt;

&lt;p&gt;Schematics can be &lt;em&gt;directives, components, pipes, modules, guards&lt;/em&gt; etc&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng generate &amp;lt;schematic-name&amp;gt; &amp;lt;sample-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Build the Angular app
&lt;/h3&gt;

&lt;p&gt;Compiles the application under the output directory named &lt;em&gt;/dist&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;ng build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  Run Unit tests in the app
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;And, that's it for today. Would you like to add anything else to the list?&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
