<?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 Haseena P A on Medium]]></title>
        <description><![CDATA[Stories by Haseena P A on Medium]]></description>
        <link>https://medium.com/@haseenakhader.uk?source=rss-635a13e9d969------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c1DqMeAPWHkupCg8m5HOnQ.jpeg</url>
            <title>Stories by Haseena P A on Medium</title>
            <link>https://medium.com/@haseenakhader.uk?source=rss-635a13e9d969------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 22:50:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@haseenakhader.uk/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[PrimeNG 19 setup in Angular 19]]></title>
            <link>https://medium.com/@haseenakhader.uk/primeng-setup-in-angular-19-2bdea5bd3c9f?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bdea5bd3c9f</guid>
            <category><![CDATA[primeng]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[primeng-setup]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Tue, 01 Apr 2025 16:07:30 GMT</pubDate>
            <atom:updated>2025-04-01T16:09:03.558Z</atom:updated>
            <content:encoded><![CDATA[<p>PrimeNG is a popular open-source UI library for Angular applications that provides an extensive collection of components with a clean design, high customization options, and great performance. Whether you’re building a complex enterprise application or a simple dashboard, PrimeNG can help you rapidly develop modern and responsive interfaces.</p><p>In this guide, we’ll walk you through the step-by-step process of setting up PrimeNG in an Angular project.</p><h3>Prequisites</h3><p>Before getting started, ensure that you have the following installed on your machine:</p><ul><li><strong>Node.js</strong> (18.19.1 or newer) — You can download nodejs from <a href="https://nodejs.org/en">here</a> if not installed already</li><li><strong>Angular CLI</strong> (latest version) — You can install using the following command npm install -g @angular/cli</li></ul><p>To verify node js and angular cli installation, you can check these versions using the following commands:</p><pre>node -v<br>ng version</pre><h4>1. Installation</h4><p>Hope you are already set up an angular project. In that case install the primeng, primeicons and primeflex using the below command</p><pre>npm install primeng @primeng/themes primeicons primeflex</pre><h4>2. Add the Provider</h4><p>Add <strong><em>providePrimeNG </em></strong>and <strong><em>provideAnimationsAsync </em></strong>to the list of providers in your<strong><em> app.config.ts</em></strong> and use the theme property to configure a theme such as Aura.</p><pre>import { ApplicationConfig, provideZoneChangeDetection } from &#39;@angular/core&#39;;<br>import { provideRouter } from &#39;@angular/router&#39;;<br><br>import { routes } from &#39;./app.routes&#39;;<br>import { provideAnimationsAsync } from &#39;@angular/platform-browser/animations/async&#39;; // add this<br>import { providePrimeNG } from &#39;primeng/config&#39;; // add this<br>import Aura from &#39;@primeng/themes/aura&#39;; // add this<br><br>export const appConfig: ApplicationConfig = {<br>  providers: [<br>    provideZoneChangeDetection({ eventCoalescing: true }),<br>    provideRouter(routes),<br>    provideAnimationsAsync(),  // add this<br>    providePrimeNG({           // add this<br>      theme: {                 // add this<br>        preset: Aura,          // add this<br>      },                       // add this<br>    }),                        // add this<br>  ],<br>};</pre><h4>3. Add PrimeFlex and Primeicon CSS files</h4><p>Styles of the installed packages can either be imported at <strong>angular.json</strong> or <strong>src/styles.css</strong> file.</p><blockquote><strong>With Angular.json ( make sure rerun the app after the below changes)</strong></blockquote><pre>&quot;styles&quot;: [<br>    &quot;node_modules/primeicons/primeicons.css&quot;,<br>    &quot;node_modules/primeflex/primeflex.css&quot;<br>    ...<br>]</pre><blockquote><strong>With styles.css</strong></blockquote><pre><br>@import &quot;primeicons/primeicons.css&quot;;<br>@import &quot;primeflex/primeflex.css&quot;;</pre><h4>4. Verify the Changes</h4><p>Verify your setup by adding a component such as Button.<br> <em>app.component.ts</em></p><pre>import { Component } from &#39;@angular/core&#39;;<br>import { RouterOutlet } from &#39;@angular/router&#39;;<br>import { ButtonModule } from &#39;primeng/button&#39;; // add this line<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  imports: [<br>    RouterOutlet, <br>    ButtonModule // add this line<br>  ],<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrl: &#39;./app.component.css&#39;,<br>})<br>export class AppComponent {<br>  title = &#39;angular-primeng-19&#39;;<br>}</pre><p><em>app.component.html</em></p><pre>&lt;div class=&quot;flex justify-content-center&quot;&gt;<br>  &lt;p-button label=&quot;Small&quot; icon=&quot;pi pi-check&quot; size=&quot;small&quot; /&gt;<br>&lt;/div&gt;</pre><p>Run the application using the following command:</p><pre>npm start</pre><p>Open your browser and navigate to http://localhost:4200, where you should see a styled button in action!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qd5hEkMjWhujVKaKbG43wg.png" /></figure><h3>Conclusion</h3><p>With PrimeNG, building professional-looking UIs in Angular becomes a breeze. In this post, we covered the essential steps to get PrimeNG up and running in your Angular project, including installing the necessary dependencies and importing components. Now, you’re all set to explore the vast world of PrimeNG components and boost your application’s UI.</p><p>Feel free to explore the <a href="https://primeng.org/">PrimeNG Documentation</a> for in-depth examples and component usage. Happy coding!</p><blockquote><em>Github Repo Reference</em> : <a href="https://github.com/haseena-pa/angular-primeng-19">https://github.com/haseena-pa/angular-primeng-19</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bdea5bd3c9f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Insertion Sort in JavaScript]]></title>
            <link>https://medium.com/@haseenakhader.uk/insertion-sort-in-javascript-45b431be9acd?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/45b431be9acd</guid>
            <category><![CDATA[insertion-sort]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 21:46:29 GMT</pubDate>
            <atom:updated>2024-01-18T21:46:29.063Z</atom:updated>
            <content:encoded><![CDATA[<p>Insertion sort is a straightforward sorting technique, like organizing a deck of cards. The array is divided into a sorted section and an unsorted section. Elements from the unsorted part are selected and inserted into their proper positions within the sorted part. This process repeats until the entire array is sorted.</p><pre>function insertionSort(arr) {<br>    for (let i = 1; i &lt; arr.length; i++) {<br>        let min = arr[i];<br>        let j = i - 1;<br>        while (j &gt;= 0 &amp;&amp; arr[j] &gt; min) {<br>            arr[j + 1] = arr[j];<br>            j = j - 1;<br>        }<br>        arr[j + 1] = min;<br>    }<br>    return arr;<br>}<br><br>insertionSort([27, 3, 7, 1, 0]);</pre><p>Let’s break down the Insertion Sort algorithm step by step based on the provided code:</p><h4>Iteration 1 (i = 1):</h4><ul><li>Selected Element (min): 3</li><li>Comparison and Swap:</li><li>Compare 3 with 27 (previous element) and swap if necessary.</li><li>Updated Array: [3, 27, 7, 1, 0]</li></ul><h4>Iteration 2 (i = 2):</h4><ul><li>Selected Element (min): 7</li><li>Comparison and Swap:</li><li>Compare 7 with 27 and move 27 to the right.</li><li>Compare 7 with 3 and place 7 in its correct position.</li><li>Updated Array: [3, 7, 27, 1, 0]</li></ul><h4>Iteration 3 (i = 3):</h4><ul><li>SSelected Element (min): 1</li><li>Comparison and Swap:</li><li>Compare 1 with 27, 7, and 3, moving elements to the right.</li><li>Place 1 in its correct position.</li><li>Updated Array: [1, 3, 7, 27, 0]</li></ul><h4>Iteration 4 (i = 4):</h4><ul><li>Selected Element (min): 0</li><li>Comparison and Swap:</li><li>Compare 0 with 27, 7, 3, and 1, moving elements to the right.</li><li>Place 0 in its correct position.</li><li>Updated Array: [0, 1, 3, 7, 27]</li></ul><p>Final Sorted Array: [0, 1, 3, 7, 27]</p><p>The algorithm iterates through the array, selecting an element (min) from the unsorted part and placing it in its correct position in the sorted part. This process continues until the entire array is sorted. The final sorted array is [0, 1, 3, 7, 27]</p><h3>Time Complexity</h3><h4>Worst Case Complexity:</h4><ul><li>Occurs when the input array is in reverse order.</li><li>Time Complexity: O(n²)</li><li>Quadratic time complexity because, for each element in the unsorted part, it may need to be compared and moved to the beginning of the sorted part.</li></ul><h4>Best Case Complexity:</h4><ul><li>Occurs when the input array is already sorted.</li><li>Time Complexity: O(n)</li><li>Linear time complexity as each element is compared to its neighbors, but no swaps are needed.</li></ul><h4>Average Case Complexity:</h4><ul><li>The average time complexity is also O(n²).</li><li>It is based on the assumption that each element is equally likely to be anywhere in the array, leading to an average behavior similar to the worst case.</li></ul><p>Insertion Sort’s efficiency is more apparent in scenarios where the array is partially sorted or small in size. For larger datasets, more efficient sorting algorithms like merge sort or quick sort are generally preferred due to their better average-case performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45b431be9acd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selection Sort in JavaScript]]></title>
            <link>https://medium.com/@haseenakhader.uk/selection-sort-in-javascript-3a7dbc161862?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a7dbc161862</guid>
            <category><![CDATA[selection-sort]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 20:58:39 GMT</pubDate>
            <atom:updated>2024-01-17T21:28:21.316Z</atom:updated>
            <content:encoded><![CDATA[<p>Selection Sort is a simple sorting algorithm that works by repeatedly finding the minimum element from the unsorted part of the array and putting it at the beginning.</p><p>Here’s how the selection sort algorithm would work for the array <br>[27, 3, 7, 1, 0]:</p><h4>Step 1:</h4><ul><li>Find the minimum element in the entire array.</li><li>Swap it with the first element.</li><li>Updated Array: [0, 3, 7, 1, 27]</li></ul><h4>Step 2:</h4><ul><li>Repeat the process for the subarray [3, 7, 1, 27].</li><li>Find the minimum element in the subarray.</li><li>Swap it with the second element.</li><li>Updated Array: [0, 1, 7, 3, 27]</li></ul><h4>Step 3:</h4><ul><li>Repeat the process for the subarray [7, 3, 27].</li><li>Find the minimum element in the subarray.</li><li>Swap it with the third element.</li><li>Updated Array: [0, 1, 3, 7, 27]</li></ul><h4>Step 4:</h4><ul><li>Repeat the process for the subarray [7, 27].</li><li>Find the minimum element in the subarray.</li><li>Swap it with the fourth element.</li><li>Updated Array: [0, 1, 3, 7, 27]</li></ul><h4><strong>Step 5:</strong></h4><ul><li>Repeat the process for the subarray [27].</li><li>Find the minimum element in the subarray.</li><li>Swap it with the fifth element.</li><li>Updated Array: [0, 1, 3, 7, 27]</li></ul><p>The array is now sorted.</p><p>Here is the code for Selection Sort in JavaScript</p><pre>const selectionSort = (arr) =&gt; {<br>  for (let i = 0; i &lt; arr.length; i++) {<br>    let lowest = i;<br>    for (let j = i + 1; j &lt; arr.length; j++) {<br>      if (arr[lowest] &gt; arr[j]) {<br>        lowest = j;<br>      }<br>    }<br>    if (i !== lowest) {<br>      // swap the elements<br>      [arr[i],arr[lowest]] = [arr[lowest], arr[i]];<br>    }<br>  }<br><br>  return arr;<br>}<br><br>selectionSort([27, 3, 7, 1, 0]);</pre><h3>Time Complexity</h3><h4>Best Case: O(n²)</h4><ul><li>The best-case scenario occurs when the array is already sorted. However, even in this case, selection sort requires scanning the entire unsorted part of the array to find the minimum element and swapping it with the first unsorted element. This results in a time complexity of O(n²).</li></ul><h4>Average Case: O(n²)</h4><ul><li>The average-case time complexity of selection sort is also O(n²). The algorithm has to perform n swaps for the first element, (n-1) swaps for the second element, and so on until the last element. This results in a sum of n + (n-1) + (n-2) + … + 1, which is proportional to n².</li></ul><h4>Worst Case: O(n²)</h4><ul><li>The worst-case scenario for selection sort occurs when the array is in reverse order or mostly in reverse order. In this case, the algorithm still needs to perform the same number of comparisons and swaps as in the average case, resulting in a time complexity of O(n²).</li></ul><p>Selection sort is not considered efficient for large datasets due to its quadratic time complexity, and other sorting algorithms like quick sort or merge sort are often preferred for better performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a7dbc161862" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bubble Sort in JavaScript]]></title>
            <link>https://medium.com/@haseenakhader.uk/bubble-sort-in-javascript-e79f1332dc51?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/e79f1332dc51</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[bubble-sort]]></category>
            <category><![CDATA[sorting-algorithms]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 21:55:35 GMT</pubDate>
            <atom:updated>2024-01-17T20:38:36.483Z</atom:updated>
            <content:encoded><![CDATA[<p>Bubble sort is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JJxJZaSQ0L1kca2DiXUkow.jpeg" /><figcaption>Visualization of bubble sort</figcaption></figure><p>Here is the code for bubble Sort</p><pre>const bubbleSort = (arr) =&gt; {<br>    let swapped;<br>    for(let i = arr.length-1 ; i &gt; 0; i--) {<br>        swapped = false;<br>        for (let j = 0; j &lt; i; j++) {<br>            if(arr[j] &gt; arr[j+1]) {<br>                [arr[j], arr[j+1]] = [arr[j+1], arr[j]];<br>                swapped = true;<br>            }<br>            <br>        }<br>        if(!swapped) break;<br>    }<br>    return arr;<br>};<br><br><br>bubbleSort([27, 3,7, 1, 0]); // Output :  [0, 1, 3, 7, 27]</pre><p>The bubbleSort function uses a flag swapped to determine whether any swaps were made during a pass through the array. If no swaps are made in a pass, it means the array is already sorted, and the function breaks out of the loop early, improving the efficiency of the algorithm.</p><p>The inner loop iterates through the array, compares adjacent elements, and swaps them if they are in the wrong order. The swapping is done using array destructuring: [arr[j], arr[j+1]] = [arr[j+1], arr[j]].</p><p>The algorithm will exit early if no swaps are made during a pass, indicating that the array is already sorted.</p><p>Let’s go through the array [27, 3, 7, 1, 0] step by step using the provided bubbleSort function:</p><h4><strong>First pass:</strong></h4><ul><li>Compare 27 and 3, swap them. Array: [3, 27, 7, 1, 0]</li><li>Compare 27 and 7, swap them. Array: [3, 7, 27, 1, 0]</li><li>Compare 27 and 1, swap them. Array: [3, 7, 1, 27, 0]</li><li>Compare 27 and 0, swap them. Array: [3, 7, 1, 0, 27]</li></ul><p>The largest element, 27, has been moved to its correct position.</p><h4>Second pass:</h4><ul><li>Compare 3 and 7, no swap. Array: [3, 7, 1, 0, 27]</li><li>Compare 7 and 1, swap them. Array: [3, 1, 7, 0, 27]</li><li>Compare 7 and 0, swap them. Array: [3, 1, 0, 7, 27]</li></ul><p>The next largest element, 7, is now in its correct position.</p><h4>Third pass:</h4><ul><li>Compare 3 and 1, swap them. Array: [1, 3, 0, 7, 27]</li><li>Compare 3 and 0, swap them. Array: [1, 0, 3, 7, 27]</li></ul><p>The next largest element, 3, is now in its correct position.</p><h4>Fourth pass:</h4><ul><li>Compare 1 and 0, swap them. Array: [0, 1, 3, 7, 27]</li></ul><p>The next largest element, 1, is now in its correct position</p><p>The array is now sorted, and the algorithm exits early because no swaps were made in the last pass (swapped is false). The final sorted array is [0, 1, 3, 7, 27].</p><h3>Time Complexity</h3><p>The Bubble Sort algorithm has different time complexities based on its performance in various scenarios:</p><h4>Worst-case complexity: O(n²)</h4><ul><li>In the worst case, Bubble Sort requires quadratic time, where n is the number of elements in the array. This occurs when the input array is in reverse order, and each element needs to be moved to its correct position through multiple passes.</li></ul><h4>Best-case complexity: O(n)</h4><ul><li>The best-case scenario for Bubble Sort is when the input array is already sorted. In this case, the algorithm still needs to make passes through the array to check for swaps but doesn’t perform any actual swaps. The time complexity is linear in the best case.</li></ul><h4>Average-case complexity: O(n²)</h4><ul><li>On average, Bubble Sort also exhibits quadratic time complexity. This is because, in typical scenarios, elements may need to be compared and swapped multiple times, leading to a time complexity of O(n²).</li></ul><h3>Efficiency</h3><p>Bubble Sort is not considered a highly efficient sorting algorithm, especially for large datasets, due to its quadratic time complexity. Other sorting algorithms like Merge Sort or QuickSort tend to perform better in practice for larger datasets. Nevertheless, Bubble Sort can still be useful for educational purposes and for small datasets where its simplicity may be advantageous.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e79f1332dc51" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular Reactive Form using PrimeNG and its Validation]]></title>
            <link>https://medium.com/@haseenakhader.uk/angular-reactive-form-using-primeng-and-its-validation-8baf6b9e7ed4?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/8baf6b9e7ed4</guid>
            <category><![CDATA[angular-primeng-example]]></category>
            <category><![CDATA[reactive-forms]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[primeng]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Fri, 11 Nov 2022 21:59:35 GMT</pubDate>
            <atom:updated>2022-11-11T21:59:54.443Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we will create a userForm with PrimeNG Components and we will generate and validate the form using the Angular Reactive form.</p><p>From PrimeNG components, we need a Card, Button and InputText.<br>From Angular Forms , we need Reactive forms</p><pre>// app.module.ts<br><br>import { NgModule } from &#39;@angular/core&#39;;<br>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br><br>// Reactive form for generate and validate the form<br>import { ReactiveFormsModule } from &#39;@angular/forms&#39;; <br><br>// primeng components<br>import { InputTextModule } from &#39;primeng/inputtext&#39;;<br>import { ButtonModule } from &#39;primeng/button&#39;;<br>import { CardModule } from &#39;primeng/card&#39;;<br><br>import { AppComponent } from &#39;./app.component&#39;;<br><br>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    ReactiveFormsModule, // &lt;- import here<br>    InputTextModule,  // &lt;- import here<br>    ButtonModule,  // &lt;- import here<br>    CardModule  // &lt;- import here<br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Lets create the form using the form builder</p><pre>// app.component.ts<br><br>import { Component } from &#39;@angular/core&#39;;<br><br>// FormBuilder to create form and Validators for validations<br>import { FormBuilder, Validators } from &#39;@angular/forms&#39;;<br><br>@Component({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent {<br><br>  userForm = this.fb.group({<br>    firstName: [&#39;&#39;, Validators.required], <br>    lastName: [&#39;&#39;],<br>    address: this.fb.group({ // &lt;- another group of element<br>      street: [&#39;&#39;],<br>      postCode: [&#39;&#39;, Validators.required]<br>    })<br>  });<br><br>  constructor(private fb: FormBuilder) { };<br><br>  addUser() {<br>    console.log(this.userForm.value);<br>  }<br><br>}</pre><pre>&lt;!-- app.component.html --&gt;<br><br>&lt;p-card styleClass=&quot;user-form&quot; class=&quot;flex justify-content-center&quot;&gt;<br>  &lt;form [formGroup]=&quot;userForm&quot; (ngSubmit)=&quot;addUser()&quot; novalidate&gt;<br>    &lt;div class=&quot;field&quot;&gt;<br>      &lt;label for=&quot;firstName&quot; class=&quot;block&quot;&gt;First Name&lt;/label&gt;<br>      &lt;input type=&quot;text&quot; pInputText placeholder=&quot;First Name&quot; formControlName=&quot;firstName&quot; /&gt;<br>      &lt;small class=&quot;p-error block&quot; *ngIf=&quot;<br>          userForm.get(&#39;firstName&#39;)?.invalid &amp;&amp; userForm.get(&#39;firstName&#39;)?.dirty<br>        &quot;&gt;<br>        First name is required&lt;/small&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;field&quot;&gt;<br>      &lt;label for=&quot;lastName&quot; class=&quot;block&quot;&gt;Last Name&lt;/label&gt;<br>      &lt;input type=&quot;text&quot; pInputText placeholder=&quot;Last Name&quot; formControlName=&quot;lastName&quot; /&gt;<br>    &lt;/div&gt;<br><br>    &lt;div formGroupName=&quot;address&quot;&gt;<br>      &lt;h2&gt;Address&lt;/h2&gt;<br>      &lt;div class=&quot;field&quot;&gt;<br>        &lt;label for=&quot;street&quot; class=&quot;block&quot;&gt;Street&lt;/label&gt;<br>        &lt;input type=&quot;text&quot; pInputText placeholder=&quot;Street&quot; formControlName=&quot;street&quot; /&gt;<br>      &lt;/div&gt;<br>      &lt;div class=&quot;field&quot;&gt;<br>        &lt;label for=&quot;postCode&quot; class=&quot;block&quot;&gt;PostCode&lt;/label&gt;<br>        &lt;input type=&quot;text&quot; pInputText placeholder=&quot;PostCode&quot; formControlName=&quot;postCode&quot; /&gt;<br>        &lt;small class=&quot;p-error block&quot; *ngIf=&quot;<br>            userForm.get(&#39;address&#39;)?.get(&#39;postCode&#39;)?.invalid &amp;&amp;<br>            userForm.get(&#39;address&#39;)?.get(&#39;postCode&#39;)?.dirty<br>          &quot;&gt;<br>          PostCode is required&lt;/small&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br><br>    &lt;button pButton type=&quot;submit&quot; label=&quot;Submit&quot; [disabled]=&quot;userForm.invalid&quot;&gt;&lt;/button&gt;<br>  &lt;/form&gt;<br>&lt;/p-card&gt;</pre><p>add some css also</p><pre>/* app.component.css */<br><br>:host &gt;&gt;&gt; .user-form {<br>  width: 30%;<br>}<br><br>:host &gt;&gt;&gt; .p-inputtext {<br>  width: 100%;<br>}</pre><p>Here is the output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*meD2ULs9ZZK5nV0mFwTIcw.png" /></figure><p>Thanks for reading…</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FHbK3uA5F7bc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DHbK3uA5F7bc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FHbK3uA5F7bc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/031558bae7b220991079517802fb0f0a/href">https://medium.com/media/031558bae7b220991079517802fb0f0a/href</a></iframe><blockquote>For More Angular PrimeNG tutorials, please follow <a href="https://medium.com/@haseenakhader.uk">https://medium.com/@haseenakhader.uk</a><br><a href="https://youtube.com/@haseena.khader">https://youtube.com/@haseena.khader</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8baf6b9e7ed4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular PrimeNG Toast (Step by Step)]]></title>
            <link>https://medium.com/@haseenakhader.uk/angular-primeng-toast-step-by-step-5ab85c0340fc?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ab85c0340fc</guid>
            <category><![CDATA[p-toast]]></category>
            <category><![CDATA[angular-primeng-example]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[primeng-toast]]></category>
            <category><![CDATA[primeng]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Sat, 05 Nov 2022 20:44:31 GMT</pubDate>
            <atom:updated>2022-11-05T20:44:31.207Z</atom:updated>
            <content:encoded><![CDATA[<p>PrimeNG Toasts are used to show messages in an overlay when any actions occur.</p><p>Below are the steps to include the PrimeNG Toast in Angular Projects</p><pre>// app.module.ts</pre><pre>import { NgModule } from &#39;@angular/core&#39;;<br>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br><strong>import { ToastModule } from &#39;primeng/toast&#39;;<br>import { BrowserAnimationsModule } from &#39;@angular/platform-browser/animations&#39;;</strong><br><strong>import { ButtonModule } from &#39;primeng/button&#39;; </strong>// if toast showing on button click<br><br>import { AppComponent } from &#39;./app.component&#39;;<br><br>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    <strong>BrowserAnimationsModule,<br>    ToastModule,<br>    ButtonModule</strong><br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p>Toast is displayed using the <strong>MessageService</strong> in primeNG</p><pre>// app.component.ts</pre><pre>import { Component } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br><strong>import { MessageService } from &#39;primeng/api&#39;;</strong></pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;],<br>  <strong>providers: [MessageService]</strong> // or import globally in module Providers<br>})<br>export class AppComponent {</pre><pre>constructor(<strong>private messageService: MessageService</strong>) { }</pre><pre>// show the toast on button click<br><strong>showToast() { <br>    this.messageService.add({severity: &#39;success&#39;, summary:  &#39;Heading&#39;, detail: &#39;More details....&#39; });<br>  }</strong><br>}</pre><p>in HTML, we will show the toast on Button click as below</p><pre>// app.component.html</pre><pre><strong>&lt;p-toast&gt;&lt;/p-toast&gt;</strong></pre><pre>&lt;!-- On Button click we will show a single toast --&gt;<br>&lt;button pButton <strong>(click)=&quot;showToast()&quot;</strong> label=&quot;show toast&quot;&gt;&lt;/button&gt;</pre><p>Output will be as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u27yDMzoUtpr2mEtzck-nA.png" /></figure><p>By default , the toast aligned <strong>top right</strong> of the window and it will close automatically after <strong>3000 ms. </strong>We have various options available in Toast to make it more customizable. We will discuss each options below.</p><h3>1. How to change the Severity of the primeNG Toast ?</h3><p>PrimeNG Toast support four values for <strong>severity — </strong>“success”, “info”, “warn” and “error”. Below are the examples</p><p>in app.component.ts instead of showing one toast, I will show all the available severity on one button click using <strong>MessageService</strong> <strong>addAll</strong> method (it accepts array of values)</p><pre>// app.component.ts</pre><pre>...</pre><pre>showToast() {<br>    this.messageService.<strong>addAll</strong>(<strong>[</strong><br>      { severity: &#39;<strong>success</strong>&#39;, summary: &#39;Heading&#39;, detail: &#39;More Details&#39; },<br>      { severity: &#39;<strong>info</strong>&#39;, summary: &#39;Heading&#39;, detail: &#39;More Details&#39; },<br>      { severity: &#39;<strong>warn</strong>&#39;, summary: &#39;Heading&#39;, detail: &#39;More Details&#39; },<br>      { severity: &#39;<strong>error</strong>&#39;, summary: &#39;Heading&#39;, detail: &#39;More Details&#39; }<br>    <strong>]</strong>);<br> }</pre><p>Output will be as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MaPV8EeBuatXxPqtUuS7Rw.png" /></figure><h3>2. How to add a custom primeNG Toast ?</h3><p>We can also add custom severity and custom icon and css to the PrimeNG Toast.</p><pre>// app.component.ts</pre><pre>showToast() {<br>    this.messageService.add(<br>      {<br>        severity: &#39;<strong>custom</strong>&#39;,<br>        summary: &#39;Custom&#39;,<br>        detail: &#39;Message Content&#39;,<br>        <strong>icon: &#39;pi-file&#39;</strong><br>      }<br>    );<br> }</pre><p>If you add the severity as any value eg: here is “custom”, then primeng Toast will generate a class (p-toast-message-&lt;severity&gt;) as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9vZFmKPH319pmYh5gBa9dQ.png" /></figure><p>If you want to apply some styling to your custom Primeng Toast, you can give. I am giving some css for now</p><pre>:host &gt;&gt;&gt; .p-toast-message-custom {<br>  background-color: #e1cfe7;<br>  border: solid #8a427a;<br>  border-width: 0 0 0 6px;<br>  color: #2c1e30;<br>}</pre><pre>:host &gt;&gt;&gt; .p-toast-icon-close {<br>  color: #2c1e30;<br>}</pre><p>and our custom primeNG Toast will look like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w9MFhqKr2LFrY2c2OxJj7g.png" /><figcaption>custom primeNG Toast</figcaption></figure><h3>3. How to add html inside primeNG Toast ?</h3><p>If we have some html content inside your toast, if we are directly giving inside the detail, it will show the message with the html tag. So the solution for this is given below</p><pre>// app.component.ts</pre><pre>showToast() {<br>    this.messageService.add(<br>      {<br>        severity: &#39;success&#39;,<br>        summary: &#39;Heading&#39;,<br>        detail: &#39;<strong>&lt;strong&gt;Message Content&lt;/strong&gt;</strong>&#39;<br>      }<br>    );<br>}</pre><p>in html , we can use the ng-template</p><pre>&lt;p-toast&gt;<br>  <strong>&lt;ng-template let-msg pTemplate=&quot;message&quot;&gt;<br>    &lt;div style=&quot;flex: 1&quot; [innerHtml]=&quot;msg.detail&quot;&gt;&lt;/div&gt;<br>  &lt;/ng-template&gt;</strong><br>&lt;/p-toast&gt;</pre><p>Output will be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56-4BIrfB8rIw9r3O5OdYQ.png" /><figcaption>PrimeNG Toast with HTML</figcaption></figure><h3>4. How to align the position of a PrimeNG Toast ?</h3><p>PrimeNG Toast support below options</p><ul><li>top-right (default)</li><li>top-left</li><li>bottom-right</li><li>bottom-left</li><li>top-center</li><li>bottom-center</li><li>center</li></ul><p>Inorder to change the position of PrimeNG Toast, you can give the position attribute to p-toast as below</p><pre>&lt;p-toast position=&quot;top-left&quot;&gt;&lt;/p-toast&gt;</pre><h3>5. How to make the PrimeNG Toast Sticky?</h3><p>By default PrimeNG Toast is automatically getting closed after 3000 ms, if you want to make it sticky, please give sticky:true as below</p><pre>// app.component.ts</pre><pre>showToast() {<br>    this.messageService.add(<br>      {<br>        severity: &#39;success&#39;,<br>        summary: &#39;Heading&#39;,<br>        detail: &#39;Message Content&#39;,<br>        <strong>sticky: true</strong><br>      }<br>    );<br>}</pre><h3>5. How to reduce/increase the PrimeNG Toast Closing Time ?</h3><p>By default, life of PrimeNG Toast is 3000 ms. You can change that as below in the code</p><pre>// app.component.ts</pre><pre>showToast() {<br>    this.messageService.add(<br>      {<br>        severity: &#39;success&#39;,<br>        summary: &#39;Heading&#39;,<br>        detail: &#39;Message Content&#39;,<br>        <strong>life: 1000</strong><br>      }<br>    );<br>}</pre><h3>5. How to clear all the PrimeNG Toast after some action ?</h3><p>For eg: if you want to clear all the PrimeNG Toast messages after some button click or any action, please use the below code inside that function trigger</p><pre>// app.component.ts<br>clearToast() {    <br>  this.messageService.<strong>clear</strong>();  <br>}</pre><h3>5. How to clear only specific PrimeNG Toast after some action ?</h3><p>For that , you can give key option to the Toast for uniquely identify</p><pre>// app.component.html</pre><pre>&lt;p-toast <strong>key=&quot;myKey1&quot;</strong>&gt;&lt;/p-toast&gt; <br>&lt;p-toast <strong>key=&quot;myKey2&quot;</strong>&gt;&lt;/p-toast&gt;</pre><pre>// app.component.ts</pre><pre>this.messageService.add({<strong>key: &#39;myKey1&#39;</strong>, severity:&#39;success&#39;, summary: &#39;Summary Text&#39;, detail: &#39;Detail Text&#39;}); this.messageService.add({<strong>key: &#39;myKey2&#39;</strong>, severity:&#39;success&#39;, summary: &#39;Summary Text&#39;, detail: &#39;Detail Text&#39;});</pre><pre>// for clearing fisrt toast<br><strong>this.messageService.clear(&#39;myKey1&#39;)</strong>;   </pre><p>For more info</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FovUupUVsa_4%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DovUupUVsa_4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FovUupUVsa_4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/123e774d7942dd2f5593dfebcd0a0003/href">https://medium.com/media/123e774d7942dd2f5593dfebcd0a0003/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ab85c0340fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PrimeNG Messages — Angular]]></title>
            <link>https://medium.com/@haseenakhader.uk/primeng-messages-angular-25cc899b63ed?source=rss-635a13e9d969------2</link>
            <guid isPermaLink="false">https://medium.com/p/25cc899b63ed</guid>
            <category><![CDATA[primeng]]></category>
            <category><![CDATA[p-messages-example]]></category>
            <category><![CDATA[p-messages-with-html]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[primeng-messages]]></category>
            <dc:creator><![CDATA[Haseena P A]]></dc:creator>
            <pubDate>Fri, 04 Nov 2022 17:25:10 GMT</pubDate>
            <atom:updated>2022-11-04T17:32:58.715Z</atom:updated>
            <content:encoded><![CDATA[<h3>PrimeNG Messages — Angular</h3><p>Messages are used to display the alert messages inline. Here are the steps to use the PrimeNG messages in your Angular Project</p><p><em>app.module.ts ( or your any other module you want to use primeNG Messages)</em></p><pre>import { NgModule } from &#39;@angular/core&#39;;<br>import { BrowserModule } from &#39;@angular/platform-browser&#39;;<br><strong>import { BrowserAnimationsModule } from &#39;@angular/platform-browser/animations&#39;;<br>import { MessagesModule } from &#39;primeng/messages&#39;;</strong></pre><pre>import { AppComponent } from &#39;./app.component&#39;;</pre><pre>@NgModule({<br>  declarations: [<br>    AppComponent<br>  ],<br>  imports: [<br>    BrowserModule,<br>    <strong>BrowserAnimationsModule,<br>    MessagesModule</strong><br>  ],<br>  providers: [],<br>  bootstrap: [AppComponent]<br>})<br>export class AppModule { }</pre><p><em>in app.component.ts</em></p><pre>import { Component, OnInit } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br><strong>import { Message } from &#39;primeng/api&#39;;</strong></pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent implements OnInit {<br>  <strong>messages1: Message[] = [];</strong></pre><pre>ngOnInit(): void {<br>    <strong>this.messages1 = [<br>      { severity: &#39;success&#39;, summary: &#39;Heading&#39;, detail: &#39;More details....&#39; },<br>      { severity: &#39;info&#39;, summary: &#39;Heading&#39;, detail: &#39;More details....&#39; },<br>      { severity: &#39;warn&#39;, summary: &#39;Heading&#39;, detail: &#39;More details....&#39; },<br>      { severity: &#39;error&#39;, summary: &#39;Heading&#39;, detail: &#39;More details....&#39; }<br>    ];</strong><br>  }</pre><pre>}</pre><p><em>in app.component.html</em></p><p>&lt;p-messages [(value)]=”messages1&quot;&gt;&lt;/p-messages&gt;</p><p><em>Below is the output</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kc2tpFLtGwP2arwmC4KBiA.png" /></figure><blockquote><strong>If you want to include any html inside detail section, you have to use</strong></blockquote><p><em>app.component.ts</em></p><pre>import { Component, OnInit } from &#39;<a href="http://twitter.com/angular/core">@angular/core</a>&#39;;<br>import { Message } from &#39;primeng/api&#39;;</pre><pre><a href="http://twitter.com/Component">@Component</a>({<br>  selector: &#39;app-root&#39;,<br>  templateUrl: &#39;./app.component.html&#39;,<br>  styleUrls: [&#39;./app.component.css&#39;]<br>})<br>export class AppComponent implements OnInit {<br>  messages1: Message[] = [];</pre><pre>ngOnInit(): void {<br>    <strong>const htmlContent = `&lt;strong&gt;More details having html&lt;/strong&gt;`;</strong><br>    this.messages1 = [<br>      { severity: &#39;success&#39;, summary: &#39;Heading&#39;, detail: <strong>htmlContent </strong>}<br>    ];<br>  }<br>}</pre><p><em>in app.component.html</em><br>&lt;p-messages [(value)]=”messages1&quot; <strong>[escape]=”false”</strong>&gt;&lt;/p-messages&gt;</p><p><em>output</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wcXFX0ne1OJgkAd_9nftrA.png" /></figure><p><em>For more available options</em></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FWyoMRtkc8vI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DWyoMRtkc8vI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FWyoMRtkc8vI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5451f2f50b4278d9fcf340e9dd748e0c/href">https://medium.com/media/5451f2f50b4278d9fcf340e9dd748e0c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25cc899b63ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>