<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by jyothi reddy on Medium]]></title>
        <description><![CDATA[Stories by jyothi reddy on Medium]]></description>
        <link>https://medium.com/@nikhijyo25?source=rss-dfb6b4514f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2P1OnRuFBKowVQwB</url>
            <title>Stories by jyothi reddy on Medium</title>
            <link>https://medium.com/@nikhijyo25?source=rss-dfb6b4514f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:27:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikhijyo25/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building blocks of Angular]]></title>
            <link>https://medium.com/@nikhijyo25/building-blocks-of-angular-e09a222b2748?source=rss-dfb6b4514f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e09a222b2748</guid>
            <dc:creator><![CDATA[jyothi reddy]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 13:17:40 GMT</pubDate>
            <atom:updated>2023-03-31T17:02:53.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*co9Qk5aEZ4GoBaWv.png" /></figure><ol><li>Components</li><li>Modules</li><li>Directives</li><li>Decorators</li><li>Pipes</li><li>Data Binding</li><li>Templates</li><li>Services</li><li>Dependency Injection</li></ol><h3>Component:</h3><p>Components are the key futures of angular. The whole angular application is built by using different components. Components are reusable parts which you can reuse very easily build applications. So this component again contains template ,class, metadata.</p><p><strong>Class:</strong></p><p>Component have a class which is nothing but a type script code. Class supports view created by template part. This class also contains data properties and member methods.</p><p><strong>Register the component in module</strong></p><pre>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br>import { NgModule } from &#39;@angular/core&#39;;<br>import { AppComponent } from &#39;./app.component&#39;;<br>import { SampleComponent } from &#39;./sample.component&#39;;<br>@NgModule({<br>  declarations: [AppComponent,SampleComponent],<br>  imports: [ BrowserModule],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }<br></pre><p>We registered the component ofthe appmodule.ts page After that We are going to declare in the samplecomponent.</p><p><strong>I Added to the element in HTML Markup.</strong></p><p>some of the markup design in the sample.component.html below code.</p><pre>&lt;h3&gt;Test Component&lt;/h3&gt;</pre><h3>Modules</h3><p>Every angular application is collection of many individual modules.A module allow you to separate functionality of your application in to independent parts .Each module independents of other. If a change is made to any module in application it does not affect other module. Angular module is nothing but group of related coding in single unit and it can be loaded eagerly when the application starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/0*4E1kAVZYMxIQXd3r.png" /></figure><p><strong>Register the component in module</strong></p><pre>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br>import { NgModule } from &#39;@angular/core&#39;;<br><br>import { AppComponent } from &#39;./app.component&#39;;<br><br>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule<br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }<br></pre><h3>Directives:</h3><p>Directive are used to extend the powerof HTML attribute and to give shape and reset to the Dom structures and let have three types of directory first one is that come component directly second one is a structural directory and third one is attribute directives so component directive is the nothing but a class just if you open the source folder that have component so here if we look that app component so that the physical this one is that class only so component a tree is nothing but a class with that component director so the component decorator so this one is that decorator and this one is that metadata because if you will look here clearly here is there this one export class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/0*oCRMfITzSD2P6VXc.png" /></figure><ol><li><strong>Structural Directives</strong></li></ol><p>Structural directives are responsible for HTML laypout. They shape or reshape the DOMs strucutre typically by adding ,removing ,manipulating elements. As with other directives you apply a structural directives to a host element. Structural directives are essay to recognize. An asterisk(*) preceds the directive attribute name as in this example.</p><p>*ngIf, *ngFor, ngSwitch &amp; *ngSwitchCase here the some of the examples of Structural Directives.</p><pre>&lt;p *ngIf = &quot;toDisplay&quot;&gt; This is a paragraph. &lt;/p&gt;<br><br>&lt;p&gt; List of users &lt;/p&gt;<br><br>&lt;ul&gt;<br>  &lt;li *ngFor = &quot;let user of userAvailable&quot;&gt;<br>    {{ user.userName }}<br>  &lt;/li&gt;<br>&lt;/ul&gt;</pre><p>2. <strong>Attribute Directives</strong></p><p>The ngclass is an attribute directive .The ng class is used to added a CSS class dynamically webpage element.</p><pre>&lt;p&gt;Passing an Array of classes:&lt;/p&gt;<br>&lt;button [ngClass]=&quot;[&#39;btn&#39;, &#39;btn-primary&#39;]&quot;&gt;Button&lt;/button&gt;</pre><h3>Decorators</h3><p>Decorators are which simply as function</p><p>Decorators is type script feature used for passing metadata</p><p>Decorators are invoked at run time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*y_TkrlUvN5dAx3Er.png" /></figure><p>Some of the decorators available are:</p><p>class Decorators: @ngModule, @Component</p><p>property decorators:@input ,@output</p><p>method decorators:@HostListner</p><p>parameter decorators:@inject</p><pre>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule<br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})</pre><p>In angular, we can have Some of the flexibility of the developing custom directives.</p><h3>Pipes</h3><p>Mostly pipes are simple functions to use in template expressions to accept an input value and return a transform value. Our pipes are denoted by a filter function or just a line now how exactly do we transform data by using pipes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/0*ueYm_00OghJFCun6.JPG" /></figure><p>Some of the pipes available are:</p><p>Currency Pipe</p><p>Date Pipe</p><p>Uppercase Pipe</p><p>Lowercase Pipe</p><p>Decimal Pipe</p><p>JSON Pipe</p><pre>// Currency Pipe {{ priceToPay | currency:&#39;INR&#39; }}</pre><h3>Data Binding</h3><ol><li>Interpolation</li><li>Property Binding</li><li>Event Binding</li><li>Two way Binding</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LSxWSQLpEImicpP-.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*HOZ3o_cyQI07WVtVqxu1YQ.png" /></figure><p>Data binding every component we have a component class and for that component class we have corresponding view<br>template</p><p>now in the component class we specifynow these properties and methods can be used in the view template of thatcomponent so as you can see inside thisview template we are using this title<br>propertyin the same way we are using the slogan property and we are also using this display property here and these properties are defined in the component class <br> You can see here so whenever the value of these property will change it will reflect in the view template that means it will also reflect in the web page<br>so here we are passing data from the component class to view template now it is also possible to pass data from view template to component class so let’s say in the web page we have a text box and whenever a user enters some value in that text box.</p><p>we want to assignthat value to a property to the property of the component class so in that case the data will transfer from view template to component class and this is what data binding is using data binding we can pass data from the component class to view template or<br>from the view template template to its corresponding component class now data binding can be classified into two types one way data binding and two-way data binding in case of one-way data binding the data flows in one direction so one-way data binding is when we can access component class property in the corresponding view template and this can be achieved using string interpolation or property binding in angularnow one way data binding also means that we can pass data from view template to its corresponding component class and this can be achieved using event binding in angula so remember that in case of one way data binding the data flows only in one direction either it will flow from component class to its corresponding view template or from the view template to its corresponding component class then we also have two-way data binding two-way data binding binds data from the component class to view template and from the view template to component class so this is a combination of property binding and event binding again let’s understand this with an example so let’s say in the web page we have a text box and whatever value user enters in that text box we want to assign that value to the property of thecomponent class in the same way whenever the value of that property changes innthe component class we want to display that value in the text box in the web page so here the data is flowing in both.</p><p>Directions and this is what a two-way data binding is so this was a very high level overview of what is data binding in angular and what are the different types of data binding available in angular from the next lecture let’s go ahead and let’s implement data binding in our angular applicationInterpolation binds any javascript variable data to the template</p><pre>&lt;p&gt; {{ name }} &lt;/p&gt;</pre><p>Property binding Example:</p><pre>&lt;app-message [message] = &quot;messageToDisplay&quot;&gt;&lt;/app-message&gt;</pre><p>Event binding Example:</p><pre>&lt;p (click) = &quot;onClick()&quot;&gt;This is paragraph &lt;/p&gt;</pre><p>Two way binding Example:</p><pre>&lt;input [(ngModel)]=&quot;user.name&quot;&gt;</pre><h3>Templates</h3><p>The Templates are basically basically defined the HTML we need use to show on our page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*7JqAn9rsz82Qw0Si.png" /></figure><p>For example the view of the component is defined through templates.</p><pre>&lt;div class = &quot;container&quot;&gt;<br>  &lt;div class = &quot;cup&quot;&gt;<br>    &lt;div class = &quot;cup-design-stripes&quot;&gt;&lt;/div&gt;<br>    &lt;div class = &quot;handle&quot;&gt;<br>      &lt;div class = &quot;handle-inside&quot;&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>  &lt;div class = &quot;cup-shadow&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><h3>Metadata</h3><p>Metadata is attached to class. This information angular needs to decide the particular class is a component and simple class. Metadata is defined using decorator which is user in type script.</p><p>Example:</p><pre>@Component({selector: &#39;app-root&#39;,templateUrl: &#39;./app.component.html&#39;,styleUrls: [&#39;./app.component.css&#39;]})</pre><h3>Services</h3><p>To consume the data in angular application coming from the server we have to do following thing write code to retrieve data inside component code it self. Such as application modularity future get disturbed .Unit testing component code become difficult or if we want to range the data multiple component in our application code rewrite each and every component facility. A service is typically a type script class with a narrow and well defined purpose . For data that is not associated with a specific view and that you want to share across multiple components you create a service class and immediatly preceded by the @injectale () decorater . Anything can be a service Examples include :logging service and data service .</p><h3><strong>Dependency Injection:</strong></h3><p>Dependency injection is a software design pattern as we have something called solid principle while working with any object-oriented base development in which S stands for single responsibility so we need to make sure whenever we are making any chunk of code it should go for a single responsibility .So, that we can use that anywhere as a independent unit alright and when we integrate that particular part with another one it will be a complimentary and bigger task so that is what about a single responsibility if you will put something multiple responsibility over a block maybe you will not be comfortable enough to reuse that maybe you want only one of the functionality out of it maybe but you are getting multiple so this is how you can go for single responsibility.</p><p>which we have seen in the functions also now there is also one principle in solid that is called dependency inversion that is will be in solid all right and this is where dependency injection comes into the picture which states like rather than providing the hard-coded value we will give the proper value through our dependency all right probably suppose we have created a service which will evaluate a value .</p><p>we will pass that particular value in a controller so this service will be like a dependency for my controller in this if I will make any configuration or chain maybe in the service it will make no effect in my controller it will keep on working as it is alright so that also makes your code loosely coupled alright so let’s see what is here it is a software design pattern components are given their dependencies no values all rightit’s specific let us say controller all</p><p>right and that makes your code reusable</p><p>constructor(private authService : AuthService) { }</p><h3><strong>Summary:</strong></h3><p>Every Angular applications containes one or more modules.The root module of application is called as App module</p><p>Each Module containes one or more component classes and service classes Every apPlication has one component as a root component or app component.</p><p>Each component contains HTML template a type script class and meta data defined with the help of @ component decorator.</p><p>Module can also has services which contains business logic of application.</p><p>In angular application module can be imported and exported and ultimately render the view of application in web browser.</p><p><strong>𝚃𝚑𝚊𝚗𝚔𝚜 𝚏𝚘𝚛 𝚛𝚎𝚊𝚍𝚒𝚗𝚐..!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e09a222b2748" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>