Macess  Hulk

Macess Hulk

1578504937

Adding Loader/Spinner In Angular 8 Application

Introduction

In a web application, we generally show a process status by graphical indicators like progress bars and spinners. In this post, we will discuss How To Add Loader/Spinner In Angular 8 Application, we will learn how we can show the Loader in Angular 8 using Ngx spinner library. Ngx spinner is a library for loading spinner for Angular, which is meant to inform the user that data loading is in progress. Basically Loader is used to show the loading state of data in application.

Prerequisites

  • Basic Knowledge of Angular 2 or higher
  • Visual Studio Code
  • Visual studio and SQL Server Management studio
  • Node and NPM installed
  • Bootstrap

Step 1

Create an Angular project by using the following command.

ng new Angularloader 

Step 2

Open this project in Visual Studio Code and install bootstrap by using following command

npm install bootstrap --save  

Now open styles.css file and add Bootstrap file reference. To add reference in styles.css file add this line.

@import '~bootstrap/dist/css/bootstrap.min.css';  

Step 3

Now install ngx spinner library in this project, to install ngx spinner library use the following command

npm install ngx-spinner --save  

Step 4

Now Update app.module.ts

Open app.module.ts file and add Import NgxSpinnerModule in the root module,

import { BrowserModule } from '@angular/platform-browser';  
import { NgModule } from '@angular/core';  
import { AppRoutingModule } from './app-routing.module';  
import { AppComponent } from './app.component';  
import { HttpClientModule } from '@angular/common/http'  
import { EmployeedetailsComponent } from './employeedetails/employeedetails.component';  
import { NgxSpinnerModule } from "ngx-spinner";  
@NgModule({  
  declarations: [  
    AppComponent,  
    EmployeedetailsComponent  
  ],  
  imports: [  
    BrowserModule,  
    AppRoutingModule,  
    HttpClientModule,  
    NgxSpinnerModule  
  ],  
  providers: [],  
  bootstrap: [AppComponent]  
})  
export class AppModule { }  

This is image title

Step 5

Now create a new component by using the following command.

ng g c Employeedetails --spec=false  

Now open employeedetails.component.ts file and import NgxSpinnerService

import { Component, OnInit } from '@angular/core';  
import { EmployeeService } from "../employee.service";  
import { Employe } from "../employe";  
import { NgxSpinnerService } from "ngx-spinner";  
@Component({  
  selector: 'app-employeedetails',  
  templateUrl: './employeedetails.component.html',  
  styleUrls: ['./employeedetails.component.css']  
})  
export class EmployeedetailsComponent implements OnInit {  
  emp: any;  
  constructor(private employeeService: EmployeeService,  
    private SpinnerService: NgxSpinnerService) { }  
  
  ngOnInit() {  
    this.GetemployeeDetails();  
  }  
  GetemployeeDetails() {  
    this.SpinnerService.show();  
    this.employeeService.GetemployeeDetails().subscribe((data: any) => {  
      this.emp = data;  
      console.log(this.emp);  
       this.SpinnerService.hide();  
    });  
  }  
}  

This is image title

Open employeedetails.component.html file and following lines

<div>    
    <div class="row" style="margin-top:10px;margin-bottom: 10px;">    
      <div class="col-sm-12 btn btn-success">    
        Loader in Angular Application with Dynamic  Data     
      </div>    
    </div>    
    <div class="row" style="margin-top:10px;margin-bottom: 10px;">    
    </div>    
  </div>    
  <hr style="background-color:black" />    
  
<div>  
    <table class="table table-dark table-striped">  
      <thead>  
        <tr>  
          <th>Id</th>  
          <th>Name</th>  
          <th>Age</th>  
          <th>Address</th>  
          <th>City</th>  
          <th>ContactNum</th>  
          <th>Salary</th>  
          <th>Department</th>  
        </tr>  
      </thead>  
      <tbody>  
        <tr *ngFor="let e of emp">  
          <td>{{e.Id}}</td>  
          <td>{{e.Name}}</td>  
          <td>{{e.Age}}</td>  
          <td>{{e.Address}}</td>  
          <td>{{e.City}}</td>  
          <td>{{e.ContactNum}}</td>  
          <td>{{e.Salary}}</td>  
          <td>{{e.Department}}</td>  
        </tr>  
      </tbody>  
    </table>  
  </div>  
  <ngx-spinner bdColor="rgba(51, 51, 51, 0.8)" size="default" type="ball-spin-clockwise">  
    <p style="color: white">Please Wait. </p>  
    </ngx-spinner>    

Step 6

Create a new class using following command,

ng g class  Employe --spec=false  

Now open employe.ts file and add the following line in this class

export class Employe {  
    Id:number;  
    Name:any;  
    Age:any;  
    Address:any;  
    City:any;  
    ContactNum:number;  
    Salary:number;  
    Department:any;  
}  

Step 7

Create a new service using following command

ng g s Employee --spec=false  

Now open employee.service.ts file and add following lines

import { Injectable } from '@angular/core';  
import { HttpClient } from "@angular/common/http";  
@Injectable({  
  providedIn: 'root'  
})  
export class EmployeeService {  
  url:any;  
  constructor(private http:HttpClient ) {   
  
  }  
  GetemployeeDetails()  
  {  
    this.url='http://localhost:56932/api/Employee/Employeedetails';  
    return this.http.get(this.url);  
  }  
}   

**Step 8 - Create database and a table **

Open SQL Server Management Studio, create a database named “Employee”, and in this database, create a table. Give that table a name like “employee”.

CREATE TABLE [dbo].[Employee](    
    [Id] [int] IDENTITY(1,1) NOT NULL,    
    [Name] [varchar](50) NULL,    
    [Age] [int] NULL,    
    [Address] [varchar](50) NULL,    
    [City] [varchar](50) NULL,    
    [ContactNum] [varchar](50) NULL,    
    [Salary] [decimal](18, 0) NULL,    
    [Department] [varchar](50) NULL,    
 CONSTRAINT [PK_Employee] PRIMARY KEY CLUSTERED     
(    
    [Id] ASC    
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]    
) ON [PRIMARY]    
    
GO    
    
SET ANSI_PADDING OFF    
GO     

Create a new Web API project

Step 9

Open Visual Studio and create a new project.

This is image title

Step 10

Change the name to LoaderDemo

This is image title

Step 11

Choose the template as Web API.

This is image title

Step 12

Right-click the Models folder from Solution Explorer and go to Add >> New Item >> data.

This is image title

Step 13

Click on the “ADO.NET Entity Data Model” option and click “Add”.

This is image title

Step 14

Select EF Designer from the database and click the “Next” button.

This is image title

Step 15

Add the connection properties and select database name on the next page and click OK.

This is image title

Step 16

Check the “Table” checkbox. The internal options will be selected by default. Now, click the “Finish” button.

This is image title

Step 17

Right-click on the Controllers folder and add a new controller. Name it as “Employee controller” and add the following namespace in the Employee controller.

using LoaderDemo.Models;  

Step 18

Now, add a method to fetch data from database.

Employee controller

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Net;  
using System.Net.Http;  
using System.Web.Http;  
using LoaderDemo.Models;  
  
namespace LoaderDemo.Controllers  
{  
    [RoutePrefix("Api/Employee")]  
    public class EmployeeController : ApiController  
    {  
        [Route("Employeedetails")]  
        [HttpGet]  
        public object Studentdetails()  
       {  
            EmployeeEntities DB = new EmployeeEntities();  
            var emp = DB.Employees.ToList();  
            return emp;  
        }  
    }  
}  

Step 19

Now, let’s enable CORS. Go to Tools, open NuGet Package Manager, search for CORS, and install the “Microsoft.Asp.Net.WebApi.Cors” package. Open Webapiconfig.cs and add the following lines.

EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "*");      
config.EnableCors(cors);    

Step 20

Now run the project and check result

This is image title

When data is load, the loader is hidden.

This is image title

Summary

In this article, we learned how we add Loader in Angular application with dynamic data load. Thank you for reading and keep visiting

#angular #angular8 #node-js #npm #sql

What is GEEK

Buddha Community

Adding Loader/Spinner In Angular 8 Application
Christa  Stehr

Christa Stehr

1598940617

Install Angular - Angular Environment Setup Process

Angular is a TypeScript based framework that works in synchronization with HTML, CSS, and JavaScript. To work with angular, domain knowledge of these 3 is required.

  1. Installing Node.js and npm
  2. Installing Angular CLI
  3. Creating workspace
  4. Deploying your First App

In this article, you will get to know about the Angular Environment setup process. After reading this article, you will be able to install, setup, create, and launch your own application in Angular. So let’s start!!!

Angular environment setup

Install Angular in Easy Steps

For Installing Angular on your Machine, there are 2 prerequisites:

  • Node.js
  • npm Package Manager
Node.js

First you need to have Node.js installed as Angular require current, active LTS or maintenance LTS version of Node.js

Download and Install Node.js version suitable for your machine’s operating system.

Npm Package Manager

Angular, Angular CLI and Angular applications are dependent on npm packages. By installing Node.js, you have automatically installed the npm Package manager which will be the base for installing angular in your system. To check the presence of npm client and Angular version check of npm client, run this command:

  1. npm -v

Installing Angular CLI

  • Open Terminal/Command Prompt
  • To install Angular CLI, run the below command:
  1. npm install -g @angular/cli

installing angular CLI

· After executing the command, Angular CLI will get installed within some time. You can check it using the following command

  1. ng --version

Workspace Creation

Now as your Angular CLI is installed, you need to create a workspace to work upon your application. Methods for it are:

  • Using CLI
  • Using Visual Studio Code
1. Using CLI

To create a workspace:

  • Navigate to the desired directory where you want to create your workspace using cd command in the Terminal/Command prompt
  • Then in the directory write this command on your terminal and provide the name of the app which you want to create. In my case I have mentioned DataFlair:
  1. Ng new YourAppName

create angular workspace

  • After running this command, it will prompt you to select from various options about the CSS and other functionalities.

angular CSS options

  • To leave everything to default, simply press the Enter or the Return key.

angular setup

#angular tutorials #angular cli install #angular environment setup #angular version check #download angular #install angular #install angular cli

Clara  Gutmann

Clara Gutmann

1598716260

Angular 8 CRUD Example | Angular 8 Tutorial For Beginners

Angular 8 CRUD is a basic operation to learn Angular from scratch. We will learn how to build a small web application that inserts, read data, update and delete data from the database. You will learn how to create a MEAN Stack web application. In this Angular 8 Tutorial Example, you will learn a new framework by building a crud application.

New features of Angular 8

You check out the new features in brief on my  Angular 8 New Features post.

I have designed this Angular 8 CRUD Tutorial, especially for newcomers, and it will help you to up and running with the latest version of Angular, which is right now 8.

#angular #angular 8 #angular 8 crud

Roberta  Ward

Roberta Ward

1595344320

Wondering how to upgrade your skills in the pandemic? Here's a simple way you can do it.

Corona Virus Pandemic has brought the world to a standstill.

Countries are on a major lockdown. Schools, colleges, theatres, gym, clubs, and all other public places are shut down, the country’s economy is suffering, human health is on stake, people are losing their jobs and nobody knows how worse it can get.

Since most of the places are on lockdown, and you are working from home or have enough time to nourish your skills, then you should use this time wisely! We always complain that we want some ‘time’ to learn and upgrade our knowledge but don’t get it due to our ‘busy schedules’. So, now is the time to make a ‘list of skills’ and learn and upgrade your skills at home!

And for the technology-loving people like us, Knoldus Techhub has already helped us a lot in doing it in a short span of time!

If you are still not aware of it, don’t worry as Georgia Byng has well said,

“No time is better than the present”

– Georgia Byng, a British children’s writer, illustrator, actress and film producer.

No matter if you are a developer (be it front-end or back-end) or a data scientisttester, or a DevOps person, or, a learner who has a keen interest in technology, Knoldus Techhub has brought it all for you under one common roof.

From technologies like Scala, spark, elastic-search to angular, go, machine learning, it has a total of 20 technologies with some recently added ones i.e. DAML, test automation, snowflake, and ionic.

How to upgrade your skills?

Every technology in Tech-hub has n number of templates. Once you click on any specific technology you’ll be able to see all the templates of that technology. Since these templates are downloadable, you need to provide your email to get the template downloadable link in your mail.

These templates helps you learn the practical implementation of a topic with so much of ease. Using these templates you can learn and kick-start your development in no time.

Apart from your learning, there are some out of the box templates, that can help provide the solution to your business problem that has all the basic dependencies/ implementations already plugged in. Tech hub names these templates as xlr8rs (pronounced as accelerators).

xlr8rs make your development real fast by just adding your core business logic to the template.

If you are looking for a template that’s not available, you can also request a template may be for learning or requesting for a solution to your business problem and tech-hub will connect with you to provide you the solution. Isn’t this helpful 🙂

Confused with which technology to start with?

To keep you updated, the Knoldus tech hub provides you with the information on the most trending technology and the most downloaded templates at present. This you’ll be informed and learn the one that’s most trending.

Since we believe:

“There’s always a scope of improvement“

If you still feel like it isn’t helping you in learning and development, you can provide your feedback in the feedback section in the bottom right corner of the website.

#ai #akka #akka-http #akka-streams #amazon ec2 #angular 6 #angular 9 #angular material #apache flink #apache kafka #apache spark #api testing #artificial intelligence #aws #aws services #big data and fast data #blockchain #css #daml #devops #elasticsearch #flink #functional programming #future #grpc #html #hybrid application development #ionic framework #java #java11 #kubernetes #lagom #microservices #ml # ai and data engineering #mlflow #mlops #mobile development #mongodb #non-blocking #nosql #play #play 2.4.x #play framework #python #react #reactive application #reactive architecture #reactive programming #rust #scala #scalatest #slick #software #spark #spring boot #sql #streaming #tech blogs #testing #user interface (ui) #web #web application #web designing #angular #coronavirus #daml #development #devops #elasticsearch #golang #ionic #java #kafka #knoldus #lagom #learn #machine learning #ml #pandemic #play framework #scala #skills #snowflake #spark streaming #techhub #technology #test automation #time management #upgrade

Benefits of Angular JS based Applications

AngularJS was introduced in the year 2009, by Google. AngularJS is a software framework used worldwide by developers. The entire base of this framework is open source. AngularJS has gained popularity among developers because of how it has become for them to create web applications. AngularJS helps in building apps that require less work and reduces the use of unnecessary codes. AngularJS application development is a javascript framework. AngularJS has a clear goal to make the entire process simpler, it also helps app development process and operations as much as it could. AngularJS is used for building applications that support MVC (model view controller) and SPAs (single page web apps) coding and programming structures. AngularJS has been used by some of the top companies in the world to simplify their app development process, like, Google, Paypal, Udemy, mobile site in iPad for HBO, etc. To read more click on the link.

#hire angular js developer #hire dedicated angular js developer #angular js application development #hire dedicated angular js team #hire best angular js application developer

Clara  Gutmann

Clara Gutmann

1598727360

Angular 8 Updates And Summary of New Features

Angular 8 Updates And Summary of New Features is today’s topic. Angular 8 arrives with an impressive list of changes and improvements including the much-anticipated Ivy compiler as an opt-in feature. You can check out  Angular 7 features and updates if you have not seen yet. In this blog, we have written some articles about  Angular 7 Crud,  Angular 7 Routing,  Angular ngClass,  Angular ngFor.

Angular 8 Updates And Summary

See the following updates.

TypeScript 3.4

Angular 8.0 is now supported TypeScript 3.4, and even requires it, so you will need to upgrade.

You can look at what  TypeScript 3.3 and  TypeScript 3.4 brings on the table on official Microsoft blog.

#angular #typescript #angular 7 crud #angular 7 routing #angular 8