<?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: Kavindu Karunasena</title>
    <description>The latest articles on DEV Community by Kavindu Karunasena (@kavindukarunasena).</description>
    <link>https://dev.to/kavindukarunasena</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%2F929788%2F9a7df141-5f38-4f0e-b9ec-a61ffdb2a360.jpg</url>
      <title>DEV Community: Kavindu Karunasena</title>
      <link>https://dev.to/kavindukarunasena</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kavindukarunasena"/>
    <language>en</language>
    <item>
      <title>What is SoftwareTesting?</title>
      <dc:creator>Kavindu Karunasena</dc:creator>
      <pubDate>Sat, 28 Dec 2024 06:24:06 +0000</pubDate>
      <link>https://dev.to/kavindukarunasena/what-is-softwaretesting-1fea</link>
      <guid>https://dev.to/kavindukarunasena/what-is-softwaretesting-1fea</guid>
      <description>&lt;p&gt;Software testing is a set of activities aimed at discovering defects and evaluating the quality of software products, known as test objects. While many assume testing is just about running tests and checking results, it’s much more than that. It involves planning, managing, and aligning with the software development lifecycle to ensure both verification (meeting requirements) and validation (meeting user and stakeholder needs).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Testing&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dynamic Testing: Involves executing the software to identify issues.&lt;/li&gt;
&lt;li&gt;Static Testing: Focuses on reviewing and analyzing the software without
execution.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Beyond the Technical Aspects&lt;/strong&gt;&lt;br&gt;
Testing isn’t purely technical. It requires intellectual effort, critical thinking, and specialized knowledge. Testers also rely on tools to assist in their work, but their expertise and analytical skills remain key to success.&lt;/p&gt;

&lt;p&gt;Effective testing reduces risks and ensures software delivers value in its operational environment, making it an indispensable part of the development process.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Exploring String Interpolation in Angular</title>
      <dc:creator>Kavindu Karunasena</dc:creator>
      <pubDate>Thu, 25 Apr 2024 05:03:39 +0000</pubDate>
      <link>https://dev.to/kavindukarunasena/exploring-string-interpolation-in-angular-2iah</link>
      <guid>https://dev.to/kavindukarunasena/exploring-string-interpolation-in-angular-2iah</guid>
      <description>&lt;p&gt;String interpolation, denoted by &lt;code&gt;{{ }}&lt;/code&gt;in Angular templates, offers a succinct means to display dynamic data. It seamlessly integrates JavaScript expressions within HTML, enabling developers to render dynamic content effortlessly.&lt;/p&gt;

&lt;p&gt;Syntax&lt;br&gt;
Using string interpolation is as simple as enclosing an expression within double curly braces. For instance:&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;Hello, {{ name }}!&amp;lt;/p&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 MyComponent {
  name: string = 'John';
}

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Here, name is a component property whose value will replace
&lt;code&gt;{{ name }}&lt;/code&gt; when rendered.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Features&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Dynamic Binding: Interpolation facilitates one-way data binding, updating the view whenever component properties change.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expression Support: It allows for a variety of expressions, including property access, method calls, arithmetic operations, and conditional statements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Readability: Interpolated expressions keep templates concise and readable, enhancing code maintainability.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Best Practices&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Simplicity: Keep templates simple and delegate complex logic to component classes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Performance: Be cautious with heavy computations in interpolation, as they can impact performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use Pipes: Employ Angular pipes for data formatting and manipulation within interpolations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String interpolation is a cornerstone of Angular's templating system, facilitating dynamic content rendering with minimal effort. By mastering its usage and adhering to best practices, developers can create responsive and maintainable Angular applications efficiently.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>stringinterpolation</category>
    </item>
    <item>
      <title>Dynamically Adding Classes with ngClass in Angular</title>
      <dc:creator>Kavindu Karunasena</dc:creator>
      <pubDate>Tue, 23 Apr 2024 14:01:49 +0000</pubDate>
      <link>https://dev.to/kavindukarunasena/dynamically-adding-classes-with-ngclass-in-angular-130k</link>
      <guid>https://dev.to/kavindukarunasena/dynamically-adding-classes-with-ngclass-in-angular-130k</guid>
      <description>&lt;p&gt;Angular's ngClass directive allows you to conditionally apply CSS classes to HTML elements based on data or expressions within your component. This provides a powerful way to control the element's appearance dynamically.&lt;/p&gt;

&lt;p&gt;Template:&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;div [ngClass]="myClasses"&amp;gt;This element's classes change dynamically!&amp;lt;/div&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;import { Component } from '@angular/core';

@Component({
  selector: 'app-my-component',
  templateUrl: './my-component.html',
  styleUrls: ['./my-component.css']
})
export class MyComponent {
  myClasses: any;
  isActive: boolean = false;

  constructor() {
    this.myClasses = {
      'highlight': this.isActive, // Class applied based on condition
      'large': true // Always applied class
    };
  }

  toggleActive() {
    this.isActive = !this.isActive;
    this.myClasses = {
      'highlight': this.isActive,
      'large': true
    };
  }
}

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

&lt;/div&gt;



&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The [ngClass] directive binds an object (myClasses) to the element's class attribute.&lt;/li&gt;
&lt;li&gt;The myClasses object contains key-value pairs where the key is the CSS class name and the value is a boolean expression.&lt;/li&gt;
&lt;li&gt;A class is added to the element only if the corresponding value in myClasses evaluates to true.&lt;/li&gt;
&lt;li&gt;You can update the myClasses object in your component's methods (e.g., toggleActive) to dynamically change the applied classes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Additional Options:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String: You can use a space-separated string to define multiple classes that are always applied.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Array: An array of strings or objects allows for combining different approaches within ngClass.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remember:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ngClass offers flexibility for conditional class application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ensure your CSS classes are defined for proper styling effects.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This approach provides a versatile way to manage class names based on your application's logic, making your Angular components more dynamic and responsive.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>ngclass</category>
    </item>
    <item>
      <title>ngFor in Angular</title>
      <dc:creator>Kavindu Karunasena</dc:creator>
      <pubDate>Mon, 22 Apr 2024 17:05:51 +0000</pubDate>
      <link>https://dev.to/kavindukarunasena/ngfor-in-angular-30b6</link>
      <guid>https://dev.to/kavindukarunasena/ngfor-in-angular-30b6</guid>
      <description>&lt;p&gt;ngFor is a built-in Angular directive that streamlines iterating over collections (arrays) in your templates. It's similar to JavaScript's for loop, but specifically designed for the world of 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-my-component',
  templateUrl: './my-component.html',
  styleUrls: ['./my-component.css']
})
export class MyComponent {
  products = [
    { name: 'Apple', price: 1.99 },
    { name: 'Banana', price: 0.79 },
    { name: 'Orange', price: 2.49 }
  ];
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the component class, we define an array named products containing objects with product details (name and price).&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;li *ngFor="let product of products"&amp;gt;
    {{ product.name }} - ${{ product.price }}
  &amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Inside the list, we use *ngFor on each &lt;/p&gt;&lt;/li&gt;
&lt;li&gt; element.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;let product: This creates a variable named product that holds the current product object during each iteration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;of products: This specifies the array to iterate over, which is the products array in this case.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Within the &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;, we display product information using interpolation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Explanation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Angular encounters *ngFor.&lt;/li&gt;
&lt;li&gt;It iterates over the products array.&lt;/li&gt;
&lt;li&gt;For each product object, it:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Creates a new &lt;/li&gt;
&lt;li&gt; element.&lt;/li&gt;
&lt;li&gt;Assigns the current product to the product variable.&lt;/li&gt;
&lt;li&gt;Renders the product name and price inside the list item.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additional Notes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;ngFor works with arrays of any data type, not just objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can access object properties within the loop using dot notation (e.g., product.name).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For more complex scenarios, you can use index to get the current item's position (*ngFor="let product of products; let i = index").&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using ngFor, you efficiently display dynamic content based on collections in your Angular applications.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>ngfor</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Conditional Rendering with ngIf in Angular</title>
      <dc:creator>Kavindu Karunasena</dc:creator>
      <pubDate>Sat, 20 Apr 2024 20:17:35 +0000</pubDate>
      <link>https://dev.to/kavindukarunasena/conditional-rendering-with-ngif-in-angular-1b0n</link>
      <guid>https://dev.to/kavindukarunasena/conditional-rendering-with-ngif-in-angular-1b0n</guid>
      <description>&lt;p&gt;In Angular applications, dynamic content based on data or user interactions is essential. The ngIf structural directive provides a powerful way to conditionally include or exclude elements from the template, ensuring a seamless user experience.&lt;/p&gt;

&lt;p&gt;Understanding ngIf&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structural Directive: ngIf modifies the DOM structure by adding or removing elements based on a condition.&lt;/li&gt;
&lt;li&gt;Expression Binding: It takes an expression as input, typically a boolean value or one that evaluates to truthy or falsy.&lt;/li&gt;
&lt;li&gt;Conditional Rendering: When the expression is true, the element and its content are displayed. If it's false, they're removed from the DOM, optimizing performance.
&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="isLoggedIn"&amp;gt;
  Welcome back!
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The *ngIf directive is placed on a div.&lt;/li&gt;
&lt;li&gt;The expression isLoggedIn controls the visibility.&lt;/li&gt;
&lt;li&gt;If isLoggedIn is true, the welcome message with the username is displayed.&lt;/li&gt;
&lt;li&gt;Otherwise, the div and its content are hidden from the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;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;div&amp;gt;
  &amp;lt;p *ngIf="value"&amp;gt;The value is true.&amp;lt;/p&amp;gt;
  &amp;lt;p *ngIf="!value"&amp;gt;The value is false.&amp;lt;/p&amp;gt;
&amp;lt;/div&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;In above code if the value is true, only display "The value is true". Otherwise display "The value is false."&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>ngif</category>
    </item>
    <item>
      <title>Two-Way Binding in Angular: Magic Mirror for Your Data</title>
      <dc:creator>Kavindu Karunasena</dc:creator>
      <pubDate>Sat, 20 Apr 2024 14:26:57 +0000</pubDate>
      <link>https://dev.to/kavindukarunasena/two-way-binding-in-angular-magic-mirror-for-your-data-1dej</link>
      <guid>https://dev.to/kavindukarunasena/two-way-binding-in-angular-magic-mirror-for-your-data-1dej</guid>
      <description>&lt;p&gt;Ever-Synced Data&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Imagine your UI reflecting changes like a magic mirror. That’s two-way data binding in Angular! It keeps your view (UI) and component data (model) constantly in sync.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Steps to Two-Way Magic&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Import FormsModule: Include it in your module (@NgModule({ imports: [FormsModule] })) for form-related directives.&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;import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'; // Import FormsModule for ngModel

import { AppComponent } from './app.component';

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;2. Use ngModel: Bind the component property to the input value with [(ngModel)]="propertyName" (like a banana in a box!).&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;import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  name = 'Angular User';
}
&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;&amp;lt;div&amp;gt;
  &amp;lt;label for="name"&amp;gt;Name:&amp;lt;/label&amp;gt;
  &amp;lt;input type="text" id="name" [(ngModel)]="name"&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;p&amp;gt;Hello, {{ name }}!&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;3. Enjoy the Magic! Changes in the input update the property, and vice versa.&lt;/strong&gt;&lt;/p&gt;

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