<?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: Karim Shabana</title>
    <description>The latest articles on DEV Community by Karim Shabana (@karim-shabana).</description>
    <link>https://dev.to/karim-shabana</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%2F421515%2Ffe6be242-601d-4493-a09b-3a17da4464e7.png</url>
      <title>DEV Community: Karim Shabana</title>
      <link>https://dev.to/karim-shabana</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karim-shabana"/>
    <language>en</language>
    <item>
      <title>Introduction to Angular Framework: Core Features</title>
      <dc:creator>Karim Shabana</dc:creator>
      <pubDate>Tue, 11 Apr 2023 22:07:19 +0000</pubDate>
      <link>https://dev.to/karim-shabana/introduction-to-angular-framework-core-features-46ji</link>
      <guid>https://dev.to/karim-shabana/introduction-to-angular-framework-core-features-46ji</guid>
      <description>&lt;h2&gt;
  
  
  What is Angular?
&lt;/h2&gt;

&lt;p&gt;Angular is a popular front-end web application development framework created by Google. It is based on TypeScript, a statically-typed superset of JavaScript, which provides additional features such as type checking and interfaces. Angular is widely used by developers worldwide due to its powerful features, ease of use, and scalability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular Core Features
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Components
&lt;/h3&gt;

&lt;p&gt;One of the core features of Angular is its component-based architecture. Components are reusable and independent building blocks of an application. They encapsulate the application's functionality and data, and can be easily added, removed, or modified. Here is an example of a simple component in Angular:&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 } from '@angular/core';

@Component({
  selector: 'app-hello-world',
  template: '&amp;lt;h1&amp;gt;Hello, World!&amp;lt;/h1&amp;gt;'
})
export class HelloWorldComponent {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we import the &lt;code&gt;Component&lt;/code&gt; decorator from the &lt;code&gt;@angular/core&lt;/code&gt; module. We then define a new component using the &lt;code&gt;@Component&lt;/code&gt; decorator, which takes an object with various properties. The &lt;code&gt;selector&lt;/code&gt; property specifies the component's name, which can be used in other components or templates to reference it. The &lt;code&gt;template&lt;/code&gt; property defines the component's HTML template. Finally, we export the component class to make it available for use in other parts of the application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Bindings
&lt;/h3&gt;

&lt;p&gt;Another important feature of Angular is its powerful data binding system. Data binding allows us to synchronize data between the component and its view, making it easy to display and manipulate data dynamically. There are four types of data binding in Angular:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interpolation: Allows us to embed expressions in the template, which are evaluated and replaced with their values at runtime. Here's an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;{{ greeting }}&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Property binding: Allows us to bind a component property to an element's property. Here's an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input [value]="name"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Event binding: Allows us to bind an element's event to a component method. Here's an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;button (click)="handleClick()"&amp;gt;Click me&amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Two-way binding: Allows us to bind a component property and an element's property to each other, so that changes in one are automatically reflected in the other. Here's an example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input [(ngModel)]="name"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Directives
&lt;/h3&gt;

&lt;p&gt;Directives are another important feature of Angular. They allow us to add behavior to HTML elements, such as showing or hiding elements, altering their appearance, or manipulating their contents. There are two types of directives in Angular:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structural directives: Alter the structure of the DOM by adding or removing elements. Examples include &lt;code&gt;*ngIf&lt;/code&gt;, &lt;code&gt;*ngFor&lt;/code&gt;, and &lt;code&gt;*ngSwitch&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div *ngIf="showMessage"&amp;gt;Hello, World!&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Attribute directives: Modify the behavior or appearance of elements by manipulating their attributes. Examples include &lt;code&gt;ngClass&lt;/code&gt;, &lt;code&gt;ngStyle&lt;/code&gt;, and &lt;code&gt;ngModel&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input [ngClass]="{ 'is-invalid': isInvalid }" [(ngModel)]="name"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Pipes
&lt;/h3&gt;

&lt;p&gt;Pipes are a useful feature of Angular that allow us to transform data before displaying it in the view. They can be used to format dates, numbers, or strings, or to filter or sort arrays. Here's an example:&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;p&amp;gt;{{ date | date: 'dd/MM/yyyy' }}&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we use the &lt;code&gt;date&lt;/code&gt; pipe to format a date in a specific format.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modules
&lt;/h3&gt;

&lt;p&gt;Modules are a way to organize an Angular application into logical units of functionality. They can be used to group related components, directives, pipes, and services, and to encapsulate them from the rest of the application. Here's an example of a simple module in Angular:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HelloWorldComponent } from './hello-world.component';

@NgModule({
  declarations: [HelloWorldComponent],
  imports: [BrowserModule],
  bootstrap: [HelloWorldComponent]
})
export class AppModule {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, we import the &lt;code&gt;NgModule&lt;/code&gt; decorator from the &lt;code&gt;@angular/core&lt;/code&gt; module. We then define a new module using the &lt;code&gt;@NgModule&lt;/code&gt; decorator, which takes an object with various properties. The &lt;code&gt;declarations&lt;/code&gt; property specifies the components, directives, and pipes that belong to the module. The &lt;code&gt;imports&lt;/code&gt; property specifies the modules that this module depends on. Finally, the &lt;code&gt;bootstrap&lt;/code&gt; property specifies the component that will be used as the root of the application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Angular is a powerful front-end web application development framework that offers a wide range of features and tools for building modern and scalable applications. Its component-based architecture, powerful data binding system, and rich set of directives, pipes, and modules make it a popular choice among developers worldwide. By mastering these core features, developers can build robust and maintainable applications that meet the needs of their users.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>frontend</category>
      <category>web</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
