<?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>Forem: Sandip Malaviya</title>
    <description>The latest articles on Forem by Sandip Malaviya (@sandipmalaviya).</description>
    <link>https://forem.com/sandipmalaviya</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%2F333781%2F9d26543e-1ede-4ffd-91b0-8d94ac8d1d58.png</url>
      <title>Forem: Sandip Malaviya</title>
      <link>https://forem.com/sandipmalaviya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sandipmalaviya"/>
    <language>en</language>
    <item>
      <title>N Level Form Array with Dynamically Validation in Angular</title>
      <dc:creator>Sandip Malaviya</dc:creator>
      <pubDate>Fri, 08 Apr 2022 06:12:15 +0000</pubDate>
      <link>https://forem.com/samarpaninfotech/n-level-form-array-with-validation-dynamically-in-angular-335a</link>
      <guid>https://forem.com/samarpaninfotech/n-level-form-array-with-validation-dynamically-in-angular-335a</guid>
      <description>&lt;p&gt;In this tutorial article, we will cover the form with multiple sub-form (nested form) along with each sub-form have custom validation in Angular.&lt;/p&gt;

&lt;h2 id="h-problem-statement"&gt;Problem Statement&lt;/h2&gt;

&lt;p&gt;Create a form with N number of sub-forms, each with N number of listed items, and submit the entire form at once, with specific validation in each form/form array.&lt;/p&gt;

&lt;h2&gt;Use Case&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Let’s say&lt;/strong&gt;, you had to create a gateway for Family Information that included basic information as well as various Address Details, Income Details, Expense Details, Education Details, Sickness Details, and so on. Furthermore, each family has several family members, and each family member has various education, spending, and income statistics. All forms contain N details and distinct fields, as well as dynamic validation when data is entered.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fZ9WaP_P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/Use-case-image-1024x618.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fZ9WaP_P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/Use-case-image-1024x618.png" alt="Use case image" width="880" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Prerequisites&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Prior knowledge of &lt;a href="https://www.tutorialspoint.com/typescript/index.htm" rel="noreferrer noopener"&gt;TypeScript&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Prior knowledge of &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps" rel="noreferrer noopener"&gt;JavaScript&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Visual studio code&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://nodejs.org/en/download/releases/" rel="noreferrer noopener"&gt;development machine&lt;/a&gt; with Node 10+ &amp;amp; NPM 5.5.1+ installed&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id="h-create-n-level-formarray-with-reactive-form-validation-in-angular-step-by-step-tutorial"&gt;Create N Level FormArray with Reactive Form Validation in Angular: Step by Step Tutorial&lt;/h2&gt;

&lt;h3&gt;Step 1: Create New Angular Project&lt;/h3&gt;

&lt;ul&gt;&lt;li&gt;Import the ReactiveFormsModule and FormsModule in app.module.ts Also, add it to the imports array of NgModule of the AppModule&lt;/li&gt;&lt;/ul&gt;

&lt;pre&gt;&lt;code&gt;import { FormsModule, ReactiveFormsModule } from '@angular/forms';&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PqsquEYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/Forms-Module-image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PqsquEYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/Forms-Module-image.png" alt="Forms Module" width="692" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Step 2: App.component.ts&lt;/h3&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;Now&lt;/strong&gt;, Create a simple form first in app.component.ts and import the below the line and add a new form something like this with validation&lt;/li&gt;&lt;/ul&gt;





&lt;pre&gt;&lt;code&gt;import { FormArray,FormBuilder,FormControl,FormGroup,Validators } from '@angular/forms';&lt;/code&gt;&lt;/pre&gt;





&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PDcv1AbN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/Form-Array-image.png" alt="Form Array image" width="692" height="477"&gt;





&lt;h3&gt;Step 3: App.component.html&lt;/h3&gt;





&lt;ul&gt;&lt;li&gt;App.component.html should look like this with a validation message message&lt;/li&gt;&lt;/ul&gt;





&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aTtpPugX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/App-component-html-code-image.png" alt="App component html code" width="692" height="433"&gt;





&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;Run the command&lt;/strong&gt;: npm start and open the browser localhost:4200/ - it will look like this and validation should fire on the touch that textbox or press submit button&lt;/li&gt;&lt;/ul&gt;





&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2V4Sz_aS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/run-the-command-image-1024x474.png" alt="run the command image" width="880" height="407"&gt;





&lt;h3&gt;Step 4: Form-Array&lt;/h3&gt;





&lt;ul&gt;
&lt;li&gt;Let’s move toward the FormArray, and try to add the first array assume we have to add the “Education Details” list.&lt;/li&gt;
&lt;li&gt;Add new member in form declaration part like this&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;&lt;code&gt;educationdata: 
this.fb.array([])&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oMmGQAFd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/form-array-code-image-1024x549.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oMmGQAFd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/form-array-code-image-1024x549.png" alt="form array code" width="880" height="472"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Step 5: Declare FormArray Function Like This&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;educationdata(): FormArray {
    return this.myForm.get('educationdata') as FormArray;
  }&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 6: Create A New Form Like This&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;neweducationdata(): FormGroup {
    return this.fb.group({
      schoolName: new FormControl(''),
      degree: new FormControl(''),
      fieldofstudy: new FormControl(''),
      startDt: new FormControl(''),
      endDt: new FormControl(''),
      grade: new FormControl(''),
      notes: new FormControl(''),
      attachmenturl: new FormControl(''),
    });
  }&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 7: Add New Array Function&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;educationcon(index) {
    this.educationList = this.myForm.get('educationdata') as FormArray;
    const formGroup = this.educationList.controls[index] as FormGroup;
    return formGroup;
  }&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 8: Remove New Array Function&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;removeeducationdata(i: number) {
    this.educationdata().removeAt(i);
  }&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 9: Add Validation Management Like This&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;educationcon(index) {
 this.educationList = this.myForm.get('educationdata') as FormArray; const formGroup = this.educationList.controls[index] as FormGroup;
    return formGroup;
}&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;&lt;li&gt;Ts code should look like this&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y4r8-ogq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/ts-code-image-1024x632.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y4r8-ogq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/ts-code-image-1024x632.png" alt="ts code" width="880" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;The HTML code should be like this&lt;/li&gt;&lt;/ul&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;table
   class="table table-bordered"
   formArrayName="educationdata"
   &amp;gt;
   &amp;lt;tr&amp;gt;
      &amp;lt;th colspan="7"&amp;gt;Add More Data:&amp;lt;/th&amp;gt;
      &amp;lt;th width="150px"&amp;gt;
         &amp;lt;button
            type="button"
            (click)="addeducationdata()"
            class="btn btn-primary"
            &amp;gt;
         Add More
         &amp;lt;/button&amp;gt;
      &amp;lt;/th&amp;gt;
   &amp;lt;/tr&amp;gt;
   &amp;lt;tr
   *ngFor="let f of educationdata().controls; let i = index"
   [formGroupName]="i"
   &amp;gt;
   &amp;lt;td&amp;gt;
      School/College Name :
      &amp;lt;input
         type="text"
         formControlName="schoolName"
         class="form-control"
         /&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      Degree:
      &amp;lt;select formControlName="degree" class="form-control"&amp;gt;
         &amp;lt;option value=""&amp;gt;Select Degree&amp;lt;/option&amp;gt;
         &amp;lt;option value="SCHOOL"&amp;gt;School Degree&amp;lt;/option&amp;gt;
         &amp;lt;option value="COLLEGE"&amp;gt;Some College&amp;lt;/option&amp;gt;
         &amp;lt;option value="BACHELOR"&amp;gt;Bachelor Degree&amp;lt;/option&amp;gt;
         &amp;lt;option value="MASTER"&amp;gt;Master Degree&amp;lt;/option&amp;gt;
         &amp;lt;option value="PHD"&amp;gt;PhD Degree&amp;lt;/option&amp;gt;
      &amp;lt;/select&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      Field Of Study:
      &amp;lt;input
         class="form-control"
         type="text"
         formControlName="fieldofstudy"
         /&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      Start Date:
      &amp;lt;input
         class="form-control"
         type="date"
         formControlName="startDt"
         /&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      End Date:
      &amp;lt;input
         class="form-control"
         type="date"
         formControlName="endDt"
         /&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      Grade:
      &amp;lt;input
         class="form-control"
         type="text"
         formControlName="grade"
         /&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      Notes:
      &amp;lt;textarea
         class="form-control"
         formControlName="notes"
         &amp;gt;&amp;lt;/textarea&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;td&amp;gt;
      &amp;lt;button
         (click)="removeeducationdata(i)"
         class="btn btn-danger"
         &amp;gt;
      Remove
      &amp;lt;/button&amp;gt;
   &amp;lt;/td&amp;gt;
   &amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;&lt;li&gt;When you run the project the UI will look like this, I have used a tab (bootstrap tab), you can add N number of an array and remove any specific array.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ExrrlkEN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/project-ui-image-1024x469.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ExrrlkEN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/project-ui-image-1024x469.png" alt="project ui" width="880" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Now Let’s Add Validation In The Nested Array&lt;/h2&gt;

&lt;h3&gt;Step 1: Add A Display Message Like This&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;validation_edumessage = {
    schoolName: [{ type: 'required', message: 'School Name is required' }],
    degree: [{ type: 'required', message: 'Degree is required' }],
    startDt: [{ type: 'required', message: 'Start Date is required' }]};&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 2: Add Validation In Education From The Group&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;neweducationdata(): FormGroup {
    return this.fb.group({
      schoolName: new FormControl('', [Validators.required]),
      degree: new FormControl('', [Validators.required]),
      fieldofstudy: new FormControl(''),
      startDt: new FormControl('', [Validators.required]),
      endDt: new FormControl(''),
      grade: new FormControl(''),
      notes: new FormControl('')}); }&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Step 3: Add Validation In Form Html Like This&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;input type="text" formControlName="schoolName"
   class="form-control" 
   [ngClass]="{'is-invalid':
    educationcon(i).controls['schoolName'].errors &amp;amp;&amp;amp;
    (educationcon(i).controls['schoolName'].dirty ||                        educationcon(i).controls['schoolName'].touched)}"/&amp;gt;

  &amp;lt;div *ngFor="let validation of validation_edumessage.schoolName"
   class="invalid-feedback"&amp;gt;
   &amp;lt;div  *ngIf="educationcon(i).controls['schoolName'].hasError(validation.type) 
&amp;amp;&amp;amp; (educationcon(i).controls['schoolName'].dirty || educationcon(i).controls['schoolName'].touched)"&amp;gt;
 &amp;lt;/div&amp;gt; &amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;&lt;li&gt;UI should look like this:&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nepfTGCK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/ui-output-image-1024x169.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nepfTGCK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/ui-output-image-1024x169.png" alt="ui output" width="880" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;When you submit a form we will get all data like this (capture from console)&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--em7YHL1H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/code-image-from-console-1024x344.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--em7YHL1H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2022/04/code-image-from-console-1024x344.png" alt="code from console" width="880" height="296"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Over To You!&lt;/h2&gt;

&lt;p&gt;Looking for a &lt;em&gt;Sample Source Code&lt;/em&gt;? Here you go: &lt;a href="https://github.com/sandipmalaviya07/nested-form-array-with-validation"&gt;GITHUB&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That’s it for now. Today you have learned how to create N Level FormArray With Reactive Form Validation using Angular. &lt;/p&gt;

&lt;p&gt;At last, If you’re dealing with large-scale applications or enterprise software, it is beneficial to take experts’ help. If you’re looking for an expert helping hand, contact Samarpan Infotech and &lt;a href="https://www.samarpaninfotech.com/hire-angularjs-developers/"&gt;hire Angular developers&lt;/a&gt; with having minimum of 5+ years of experience working on enterprise software.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>tutorial</category>
      <category>typescript</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Monitor Real-time Consolelogs from action on HTML page using Socket.io</title>
      <dc:creator>Sandip Malaviya</dc:creator>
      <pubDate>Fri, 24 Apr 2020 08:59:49 +0000</pubDate>
      <link>https://forem.com/samarpaninfotech/monitor-real-time-consolelogs-from-action-on-html-page-using-socket-io-31nd</link>
      <guid>https://forem.com/samarpaninfotech/monitor-real-time-consolelogs-from-action-on-html-page-using-socket-io-31nd</guid>
      <description>&lt;p&gt;When we need to get a real-time response in our IOS APP, we often use &lt;a href="https://nodejs.org/en/" rel="noreferrer noopener"&gt;Node.js&lt;/a&gt; to resolve this problem. and generally, we are using a console log to debug or check the output at the backend. &lt;span&gt;But these things are only can be helpful when we run a project at the localhost&lt;/span&gt;.&lt;/p&gt;

&lt;p&gt;Now, what if we need to check logs or error after uploading at the server. We get logs from servers and check logs one by one to sort out. But this solution takes a huge amount of time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there any way to short it out in less amount of time? &lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;YES, you are at the right place, In this blog, we will see how can we print or display console log real-time in HTML page so we can see logs easily. &lt;strong&gt;Here is&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
&lt;strong&gt;Step-by-step solution &lt;/strong&gt;Print / Display Console Log real-time in HTML page&lt;/h2&gt;

&lt;h3&gt;Step 1: Create New Project and Declare or assign basic or important variables&lt;/h3&gt;

&lt;p&gt;Firstly we need to create a sample node.js project and then we need to create some sample functions to print of debug logs in the typescript page. &lt;/p&gt;

&lt;p&gt;Here we are using Index.ts . And for output or display logs we are going to use Index.HTML. So let’s start the project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fnew-project-creation-index.ts_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fnew-project-creation-index.ts_.png" alt="New Nodejs Project creation using index.ts"&gt;&lt;/a&gt;New Nodejs Project creation&lt;/p&gt;

&lt;p&gt;So as per snippet, first we need to declare or assign basic or important variables for a project, and now we are rapidly moving on logic for display real-time logs,&lt;/p&gt;

&lt;h3&gt;Step 2: Logic for (display) Logs in Index.ts&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FLogic-for-display-Logs-in-Index.ts_.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FLogic-for-display-Logs-in-Index.ts_.png" alt="Logic for display Logs in Index.ts"&gt;&lt;/a&gt;Logic for display Logs in Index.ts&lt;/p&gt;

&lt;p&gt;As per code snippet, we need to create a new function and then it will call every time when console.log is executed and it will pass the message as a data parameter.&lt;/p&gt;

&lt;p&gt;It will call &lt;strong&gt;eventEmitter&lt;/strong&gt; which will be call logging function and which will pass as log message to HTML page so quickly we now we look at HTML page for better explanations.&lt;/p&gt;

&lt;h3&gt;Step 3: Display logic in HTML page&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FDisplay-logic-in-HTML-page.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FDisplay-logic-in-HTML-page.png" alt="Display logic in HTML page"&gt;&lt;/a&gt;Display logic in HTML page&lt;/p&gt;

&lt;p&gt;So as per the above snippet; listener method "&lt;strong&gt;log_messege&lt;/strong&gt;" getting called from index.ts page every time when ‘logging’ function called. It will pass data as msg parameter and it will append in HTML element as text format. &lt;/p&gt;

&lt;p&gt;Next, we move on to example for better explanations.&lt;/p&gt;

&lt;h3&gt;Step 4: Create Sample project and create functions&lt;/h3&gt;

&lt;p&gt;For example, we are going to create functions in the typescript page and put logs inside in the function. so check out next snippet,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FCreate-Sample-project-and-functions-in-typescript-page.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FCreate-Sample-project-and-functions-in-typescript-page.png" alt="Create Sample project and  functions in typescript page"&gt;&lt;/a&gt;Create Sample project and  functions in typescript page&lt;/p&gt;

&lt;p&gt;Whenever connection established then "&lt;strong&gt;connection&lt;/strong&gt;" will be called and a log will be executed and it will print. After that, we create new function &lt;strong&gt;FirstFunction&lt;/strong&gt; and whenever it calls it will execute console.log, &lt;/p&gt;

&lt;p&gt;Now, we are going to create more functions so we can be more clear about this functionality so please check out next snippet,&lt;/p&gt;

&lt;h4&gt;Step 5: Create sample functions in HTML page and design button to create event&lt;/h4&gt;

&lt;p&gt;As per function ‘FirstFunction ’ function,  ‘SecondFunction’ and ‘ThirdFunction’ will work same but log message is different.&lt;/p&gt;

&lt;p&gt;Now we quickly move on HTML page to use these functions,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcreate-sample-functions-in-HTML-page.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcreate-sample-functions-in-HTML-page.png" alt="create sample functions in HTML page"&gt;&lt;/a&gt;create sample functions in HTML page&lt;/p&gt;

&lt;p&gt;We create a function in the HTML page for a call. These listener methods in HTML page and gave name ‘First’, ’Second’, ’Third’.&lt;/p&gt;

&lt;p&gt;Now, we will design HTML element button to execute this function's runtime,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fdesign-button-to-create-event.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fdesign-button-to-create-event.png" alt="design button to create event"&gt;&lt;/a&gt;design button to create event&lt;/p&gt;

&lt;p&gt;You can see we also design "&lt;strong&gt;ul&lt;/strong&gt;" in this page also, So using this "ul" we will print logs on the screen. And we call functions &lt;strong&gt;onClick&lt;/strong&gt; event of the button, we will watch &lt;strong&gt;log_message&lt;/strong&gt; method again so we can be more clear as we do it in &lt;strong&gt;Step 3.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FDisplay-logic-in-HTML-page-1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2FDisplay-logic-in-HTML-page-1.png" alt="Display logic in List View on HTML page"&gt;&lt;/a&gt;Display logic in List View on HTML page&lt;/p&gt;

&lt;p&gt;Now, log message will append as list in the screen so we can see logs; all logs one by one. Next, we are going to run a project and let see this method is working or not.&lt;/p&gt;

&lt;h4&gt;Step 6: Execute project and check output&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fexecute-project-and-check-first-output-1024x109.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fexecute-project-and-check-first-output-1024x109.png" alt="execute project and check first output"&gt;&lt;/a&gt;execute project and check first output&lt;/p&gt;

&lt;p&gt;We can see there is some text on a screen. That is a log message which we put in the "&lt;strong&gt;Connection&lt;/strong&gt;" method and we also discussed that it will execute when connection established so following is the output of this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fexecute-project-and-check-first-function-output.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fexecute-project-and-check-first-function-output.png" alt="execute project and check first function output"&gt;&lt;/a&gt;execute project and check first function output&lt;/p&gt;

&lt;p&gt;Now, we are going to call first function and let see log is print real time in screen or not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcheck-first-function-output-printed-on-HTML-Page.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcheck-first-function-output-printed-on-HTML-Page.png" alt="calling first function to check output printed on HTML Page"&gt;&lt;/a&gt;calling first function to check output printed on HTML Page&lt;/p&gt;

&lt;p&gt;At last, we can see log message successfully print on screen real time for first method. Following, we click on second or third function and let see its work fine or not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcheck-final-project-all-function-print-console-logs-output-1024x153.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.samarpaninfotech.com%2Fwp-content%2Fuploads%2F2020%2F04%2Fcheck-final-project-all-function-print-console-logs-output-1024x153.png" alt="check final project all function print console logs output"&gt;&lt;/a&gt;check final project all function print console logs output&lt;/p&gt;

&lt;p&gt;From the above screenshot, we can see it is working fine and we are getting logs real-time on a screen for all methods. Hope you can understand functionality properly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thank You. That’s it for now. Stay Connected for more tutorials, until than Happy Coding…&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;We're always happy to assist you to turn your business development ideas into beautiful reality&lt;/em&gt;; you can &lt;a href="https://www.samarpaninfotech.com/hire-nodejs-developers/" rel="noreferrer noopener"&gt;hire our node.js developers&lt;/a&gt; for further assistance with easy hiring model.&lt;/p&gt;

</description>
      <category>node</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>html</category>
    </item>
    <item>
      <title>Angular: Create Custom Dynamic Loader OR Spinner on HTML Element</title>
      <dc:creator>Sandip Malaviya</dc:creator>
      <pubDate>Fri, 21 Feb 2020 10:30:13 +0000</pubDate>
      <link>https://forem.com/samarpaninfotech/angular-create-custom-dynamic-loader-or-spinner-on-html-element-2f3c</link>
      <guid>https://forem.com/samarpaninfotech/angular-create-custom-dynamic-loader-or-spinner-on-html-element-2f3c</guid>
      <description>&lt;p&gt;In this article, we’ll learn how we can show loader or spinner on a specific element of an HTML form using &lt;a rel="noreferrer noopener" href="https://angular.io/"&gt;Angular 8&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;Prerequisites:&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Prior knowledge of &lt;a href="https://www.typescriptlang.org/docs/home.html" rel="noreferrer noopener"&gt;TypeScript&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Prior knowledge of &lt;a rel="noreferrer noopener" href="https://www.w3schools.com/js/js_intro.asp"&gt;JavaScript&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Visual studio code.&lt;/li&gt;
&lt;li&gt;A development machine with Node 8.9+ &amp;amp; NPM 5.5.1+ installed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;Step 1: Installing Angular CLI 8&lt;/h2&gt;

&lt;p&gt;In the First step, we’ll have to install the latest version of &lt;a href="https://cli.angular.io/" rel="noreferrer noopener"&gt;Angular CLI&lt;/a&gt; using below command.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ npm install -g @angular/cli&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 2: Creating your Angular 8 Project&lt;/h2&gt;

&lt;p&gt;In this second step, we will use Angular CLI to start our Angular Project.&lt;/p&gt;

&lt;p&gt;Go to CMD or Terminal and use below command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ng new custom-loader&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This CLI will ask you &lt;em&gt;“whether you would like to add Angular routing”&lt;/em&gt;: &lt;strong&gt;Say Yes.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It will ask &lt;em&gt;“which stylesheet format you would like to use”&lt;/em&gt;. &lt;strong&gt;Choose CSS&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now your project is ready Angular CLI will generate required files and folders along with NPM packages and routing too.&lt;/p&gt;

&lt;p&gt;After that, open your project in Visual studio code and &lt;strong&gt;go to your root folder&lt;/strong&gt; and run the local development server using below command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ npm start&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--o05LHxoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Angular-8-Project-Creation-Process-1024x363.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o05LHxoG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Angular-8-Project-Creation-Process-1024x363.png" alt="Angular 8 Project Creation Process" width="880" height="312"&gt;&lt;/a&gt;Angular 8 Project Creation Process&lt;/p&gt;

&lt;p&gt;Now run &lt;strong&gt;localhost:4200/&lt;/strong&gt; in your browser.&lt;/p&gt;

&lt;h2&gt;Step 3: Add Custom JS and Image of loader&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Now add JS and image folder inside of assets folder of project.&lt;/li&gt;
&lt;li&gt;Add JavaScript file inside JS folder with name &lt;em&gt;“custom.js”&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Add any of your loader image inside image folder with name &lt;em&gt;“loader.gif”&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Add &lt;strong&gt;jquery&lt;/strong&gt; &amp;amp; &lt;strong&gt;custom.js&lt;/strong&gt; in &lt;strong&gt;angular.json&lt;/strong&gt; folder of your project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mA5KQ3Aj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Add-Custom-JS-and-Image-of-loader-Step.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mA5KQ3Aj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Add-Custom-JS-and-Image-of-loader-Step.png" alt="Code Snippet of Add Custom JS and Image of loader Step" width="880" height="510"&gt;&lt;/a&gt;Code Snippet of Add Custom JS and Image of loader Step&lt;/p&gt;

&lt;p&gt;After executing above steps, &lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;Open your custom js file and copy this below code&lt;/strong&gt;&lt;/h4&gt;

&lt;pre&gt;&lt;code&gt;function loadingServiceShow(zindex, id, flag) {
    try {
        var _id = $("[data-loader=" + id + "]");
        _id.CenterLoader(zindex, id, flag);
    } catch (error) {
        loadingServiceHide(id);
    }
}
$.fn.CenterLoader = function (zindex, id, flag) {
    var height = $(this).outerHeight() + "px";
    var width = $(this).outerWidth() + "px";
    var top = $(this).offset().top;
    var left = $(this).offset().left;
    var loadingContainer = "body";
    if (flag == true) {
        top = 0;
        left = 0;
        loadingContainer = this;
    }
    var centerTop = Math.max(0, (($(this).outerHeight() / 2) - 7)) + "px";
    var centerLeft = Math.max(0, (($(this).outerWidth() / 2) - 7)) + "px";

    var loadingContain;
    if (id === "" || id === null || id === undefined) {
        id = "loader-image";
    } else {
        var _loadIdAppend = id
        id = id + "_Loader";
    }
    loadingContain = "&amp;lt;div style='position:absolute;height:" + height + ";width:" + width + ";background:#ccc;z-index:" + zindex + ";top:" + top + "px;left:" + left + "px;opacity:0.7' id='" + id + "' class='loader-image'&amp;gt;&amp;lt;div style='position:absolute;top:" + centerTop + ";left:" + centerLeft + ";color:white;height: 28px;width: 28px;background: transparent url(assets/image/loader.gif) no-repeat scroll 0 0;' class='loader-style'&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;";
    if (flag == true) {
        loadingContain = "&amp;lt;div style='position:fixed;height:100%;width:100%;background:#ccc;z-index:" + zindex + ";top:0;left:0;opacity:0.7;'id='" + id + "' class='loader-image'&amp;gt;&amp;lt;div style='position:absolute;top:49%;left:49%;color:white;height: 28px;width: 28px;background: transparent url(assets/image/loader.gif) no-repeat scroll 0 0;'class='loader-style'&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;"
    }
    $("body").append(loadingContain);
}
function loadingServiceHide(id) {
    if (id === "" || id === null || id === undefined) {
        $(".loader-image").remove();
    } else {
        $("#" + id + "_Loader").remove();
    }
}&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;Step 4: How to use Custom.js to make Call Custom Dynamic Loader&lt;/h2&gt;

&lt;p&gt;Open &lt;em&gt;&lt;span&gt;app.component.html&lt;/span&gt;&lt;/em&gt; page and add any HTML component like&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NnSGRopB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Adding-HTML-component.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NnSGRopB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Adding-HTML-component.png" alt="Adding HTML Component in app.component.html file" width="880" height="155"&gt;&lt;/a&gt;Adding HTML Component&lt;/p&gt;

&lt;p&gt;Must add &lt;strong&gt;data attribute&lt;/strong&gt; &lt;strong&gt;&lt;span&gt;data-loader="Unique Identity"&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next, Open relevant &lt;em&gt;component.ts&lt;/em&gt; file and declare JavaScript function above &lt;em&gt;@component&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6HCkITFF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Declaring-JavaScript-Function.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6HCkITFF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Declaring-JavaScript-Function.png" alt="Declaring JavaScript Function" width="647" height="187"&gt;&lt;/a&gt;Declaring JavaScript Function&lt;/p&gt;

&lt;h2&gt;Step 5: How to Start Loader on a specific Element&lt;/h2&gt;

&lt;p&gt;For loading start, you have to add this line (For full-screen loader you just have to pass “true” in the last argument)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For Specific element - &lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;loadingServiceShow(1, 'loginbtnadd', false);&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;For Full screen - &lt;/strong&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;loadingServiceShow(1, 'loginbtnadd', true);&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now let me show you how to use that function in &lt;em&gt;&lt;strong&gt;ts code file&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YXKdd7Np--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/function-in-ts-code-file.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YXKdd7Np--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/function-in-ts-code-file.png" alt="function implementation in ts code file" width="880" height="133"&gt;&lt;/a&gt;ts code file&lt;/p&gt;

&lt;h2&gt;Step 6: How to Stop loader from specific Element&lt;/h2&gt;

&lt;p&gt;For stop you have to add this below line of command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;loadingServiceHide('loginbtnadd');&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Output as Below&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--btARrPkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Angular-8-Custom-Dynamic-Loader-on-HTML-elements.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--btARrPkR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.samarpaninfotech.com/wp-content/uploads/2019/12/Angular-8-Custom-Dynamic-Loader-on-HTML-elements.gif" alt="Angular Custom Dynamic Loader - Spinner on HTML elements" width="880" height="481"&gt;&lt;/a&gt;Angular Custom Dynamic Loader/Spinner on HTML elements Demo&lt;/p&gt;

&lt;h4&gt;Over to YOU!&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Looking for a Sample Source Code?&lt;/strong&gt;&lt;/em&gt; Here you go: &lt;a rel="noreferrer noopener" href="https://github.com/sandipmalaviya07/custom-loader-on-form-element/tree/master/custom-loader"&gt;&lt;strong&gt;&lt;em&gt;GITHUB&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Today you have learn how to create custom dynamic loader on HTML Element using Angular 8. If you have queries about tutorial, please ask our &lt;a rel="noreferrer noopener" href="https://www.samarpaninfotech.com/hire-angularjs-developers/"&gt;Angular Expert&lt;/a&gt; via GitHub Profile.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related Resources:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;a rel="noreferrer noopener" href="https://dev.to/sandipmalaviya/angular-ie-error-uncaught-in-promise-loading-chunk-3pa"&gt;How to Load Dynamic HTML Div Content In Angular Tutorial with Source Code&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;That's it for now. Stay Connected for more tutorials, until than Happy Coding...&lt;/p&gt;

</description>
      <category>angular</category>
      <category>typescript</category>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Solution for Angular IE Error: Uncaught (in promise) Loading chunk</title>
      <dc:creator>Sandip Malaviya</dc:creator>
      <pubDate>Wed, 12 Feb 2020 13:49:11 +0000</pubDate>
      <link>https://forem.com/samarpaninfotech/angular-ie-error-uncaught-in-promise-loading-chunk-3pa</link>
      <guid>https://forem.com/samarpaninfotech/angular-ie-error-uncaught-in-promise-loading-chunk-3pa</guid>
      <description>&lt;p&gt;In this article, angular developer will learn the most common error's solution which is: &lt;strong&gt;&lt;em&gt;"Uncaught (in promise) Loading chunk"&lt;/em&gt;&lt;/strong&gt; Angular &amp;amp; IE. Developer is facing this error while working with angular and IE browser, Yes App is running fine with chrome &amp;amp; another browser but not in internet explorer.&lt;/p&gt;

&lt;h2&gt;#2 Step to solve Internet explorer &amp;amp; Angular Error: Uncaught (in promise): Loading chunk&lt;/h2&gt;

&lt;p&gt;After researching some hours; we finally found solution and that issue about &lt;strong&gt;promise((t,n)=&amp;gt;,&lt;/strong&gt; promise keyword does not supporting in IE.&lt;/p&gt;

&lt;h2&gt;STEP 1: Open the src/polyfills.ts file, and uncomment below code&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;&lt;li&gt;lambda expression does not support in IE so we can replace with code function() instead of this expression.&lt;/li&gt;&lt;/ul&gt;

&lt;h2&gt;STEP 2: Install some packages as below&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;npm install --save web-animations-js
npm install --save classlist.js&lt;/code&gt;&lt;/pre&gt;

&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Then We found promise issue from one of the npm package (fuctbase64/index.js)&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;pre&gt;&lt;code&gt;module.exports = function (event) {
  return new Promise((resolve, reject) =&amp;gt; {
    let reader = new FileReader();
    let files = event.target.files;
    let len = files.length;
    if (len &amp;gt; 1) {
      reject(new DOMException("Only one file can be uploaded at a time"));
    } else {
      reader.onerror = () =&amp;gt; {
        reader.abort();
        reject(new DOMException("Problem parsing input file."));
      };
      let file = files[0]
      reader.onload = (evt) =&amp;gt; {
        const uint = new Uint8Array(evt.target.result);
        let bytes = [];
        uint.map(byte =&amp;gt; {
          bytes.push(byte.toString(16));
        });
        const hex = bytes.join('').toUpperCase();
        let base64 = reader.result.split(',')[1];
        file.base64 = base64;
        file.binaryFileType = getMimetype(hex);
        resolve(file);
      };
      reader.readAsDataURL(file);
    }
  });
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Replace code with&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;module.exports = function (event) {
  return new Promise(function(resolve, reject)  {
    let reader = new FileReader();
    let files = event.target.files;
    let len = files.length;
    if (len &amp;gt; 1) {
      reject(new DOMException("Only one file can be uploaded at a time"));
    } else {
      reader.onerror = function() {
        reader.abort();
        reject(new DOMException("Problem parsing input file."));
      };
      let file = files[0]
      reader.onload = function(evt){
        const uint = new Uint8Array(evt.target.result);
        let bytes = [];
        uint.map(function(byte) {
          bytes.push(byte.toString(16));
        });
        const hex = bytes.join('').toUpperCase();
        let base64 = reader.result.split(',')[1];
        file.base64 = base64;
        file.binaryFileType = getMimetype(hex);
        resolve(file);
      };
      reader.readAsDataURL(file);
    }
  });
}&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Over To You!&lt;/h3&gt;

&lt;p&gt;Check out full &lt;a rel="noreferrer noopener" href="https://stackoverflow.com/questions/55180018/internet-explorer-angular-6-error-error-uncaught-in-promise-error-loading"&gt;StackOverFlow thread&lt;/a&gt; for more details about solution.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>typescript</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
