Skip to content
  • iImagine
  • Register
  • Log In

Web Development School

Learning made easy.

  • Books
    • Beginning Web Development with ASP.Net Core & Client-Side Technologies
      • TOC
      • Part 1
        • Chapter 1: Static HTML – Designing the landing page
      • Part 2
        • Chapter 2: ASP.Net Core – Let’s talk Dynamic
        • Chapter 3: Introduction to ASP.Net Core MVC
          [ASP.Net Core v9]
      • Part 4
        • Chapter 7: Using Server Side & Client Side technologies together
          [ASP.Net Core v7 & Angular 15]
  • Environment Setup
    • Installing Angular
    • Installing Visual Studio 2022
    • Installing SQL Server 2022 Express
    • Installing Postman
    • Installing Git for Windows
  • Blog
  • iImagine WebSolutions
  • Events
  • Learning Videos
  • Toggle search form

Loading: Using a Progress Spinner

Now that we are using MatTable to display the Vehicle results in the Vehicles component, let’s make one more tweak before moving on to paging and sorting. Let’s turn our attention to the “Loading…” message.

Note: At this point I am copying the project from the Module16 folder to a Module17 folder. The pathway I am using for development here is:
C:\Development\FredsCars\FullStack\Module17.
Table Of Contents
  1. The current Loading… message
  2. Import the Progress Spinner Module
  3. Use Progress Spinner in Vehicles HTML
  4. Test the Progress Spinner
  5. What's Next

The current Loading… message

Right now when the Vehicles component is loading, you just see text on the screen that says “Loading like this.

Which is rendered in a simple <p> element like this:

<p *ngIf="!vehicles"><em>Loading...</em></p>

This is fine and does the job. But let’s make it look a little more professional. We can replace the “Loading…” text with a spinner from the Angular Material component library called Progress Spinner. Let’s do that now.

Import the Progress Spinner Module

Open the angular-material.module.ts file and modify it with the contents below.

FredsCars/src/app/angular-material.module.ts

import { NgModule } from '@angular/core';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatTableModule } from '@angular/material/table';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';

const angularMatModules = [
  MatToolbarModule,
  MatIconModule,
  MatButtonModule,
  MatTableModule,
  MatProgressSpinnerModule

]

@NgModule({
  imports: [
    angularMatModules
  ],
  exports: [
    angularMatModules
  ]
})
export class AngularMaterialModule { }

In the code above we import the MatProgressSpinner module into our AngularMaterialModule so we can use the Progress Spinner in the Vehicles Component HTML.

Use Progress Spinner in Vehicles HTML

Open the vehicles.component.html file and modify the contents with the following in bold blue font.

FredsCars/src/app/vehiclesvehicles.component.html

<p *ngIf="!vehicles">
  <mat-spinner style="margin: 0 auto;"></mat-spinner>
</p>

<table mat-table [dataSource]="vehicles"
       *ngIf="vehicles">

<!-- existing code -->

In the code above we simply replaced the old <em>Loading...</em> html with an AM Progress Spinner Component and centered it with an inline style.

Test the Progress Spinner

If you are developing the Angular application and you have your application and database running on the same machine, the Vehicles component may load so fast you never see the loading message or spinner. If that’s the case you can’t really tell if the Spinner is working properly.

Let’s temporarily comment out the http.get() call in the ngInit() function so the vehicles property will still be null. Then we can see the Progress Spinner in action.

Commenting out http.get() call in ngInit() in the FredsCarssrc/app/vehicles/vehicles.component.ts file.

/* existing code */

ngOnInit() {
    //this.http.get<Vehicle[]>(environment.baseUrl + 'api/vehicles').subscribe(result => {
    //  this.vehicles = result;
    //}, error => console.error(error));
  }

/* existing code */

And now the results in your browser should look similar to the following.

Of course I can’t really capture the spinning motion in a screenshot but you get the idea.

Now uncomment the http.get() call we just commented out in FredsCarssrc/app/vehicles/vehicles.component.ts so the application can once again show the vehicle results in the Vehicles component.

What’s Next

In this module we stopped for a little house cleaning and replaced the plain “Loading…” message with an Angular Material Progress Spinner. In the next module we will return to the MatTable in the Vehicles Component and implement Paging and Sorting.

< Prev
Next >

Leave a ReplyCancel reply

Chapter 1: Static HTML – Designing the landing page.

  • Static HTML – Designing the landing page.
  • Let’s get started!
  • Mock your site with HTML
  • Make CSS easy with Bootstrap
  • Mock your content
  • Introducing JavaScript
  • JavaScript Code Improvements
  • Results Data
  • Images and the HTML Image Element.
  • Revisiting Reusability for CSS and JavaScript
  • Reuse for HTML: PART 1
  • Reuse for HTML: PART 2
  • Details Page – Using a Bootstrap Component
  • Creating Links
  • Chapter One Conclusion

Chapter 2: ASP.Net Core – Let’s talk Dynamic

  • Introduction to ASP.Net Core
  • What is .Net?
  • What is ASP.Net
  • Introduction to Entity Framework Core

Chapter 3: ASP.Net MVC Core – Models, Views, and Controllers [ASP.Net Core v9]

  • Introduction to ASP.Net Core MVC
  • Create the project: ASP.Net Core MVC
  • Explore the ASP.Net Core Empty Web Project Template
  • Configure the Application for MVC
  • Create a Controller: Home Controller
  • Create a View: Index View for the Home Controller
  • Install Bootstrap using Libman
  • Create the Layout template
  • Create the Model
  • Install EF Core & Create the Database
  • Seed the Database: Loading test data
  • DI (Dependency Injection): Display a List of Vehicles
  • Repository Pattern: The Vehicles Repo
  • Unit Test 1: Home Controller Can Use Vehicle Repository
  • Unit Test 2: Vehicle Repository Can Return List
  • Add the ImagePath Migration and Thumbnail images to results
  • Pagination: Create a Custom Tag Helper
  • Sorting
  • Category Filter
  • Partial View: Break out the vehicle results
  • View Component: Create dynamic category buttons
  • Create the Details page
  • Create the Create Page

Chapter 7: Using Server Side & Client Side technologies together. [ASP.Net Core v7 & Angular v15]

  • Intro to Full Stack Development
  • Fred’s Cars – Full Stack Development
  • Prepare the environment
  • Create the Visual Studio Solution
  • Add the ASP.Net Core Web API project
  • Add the Angular Project
  • Wire it up!
  • WeatherForecast: Understanding the basics
  • Vehicles API Controller: Mock Data
  • Vehicles Angular Component: Consuming Data
  • Routing and Navigation
  • Using a Component Library: Angular Material
  • Our first Angular Material Component: MatToolbar
  • Configuring for Saas: CSS with superpowers
  • Create the Header & Footer components
  • Displaying Results with MatTable
  • Loading: Using a Progress Spinner
  • MatTable: Client-Side Paging and Sorting
  • MatSidenav: Create a Search Sidebar
  • MatCheckbox: Category Search UI
  • Adding an image to the welcome page
  • Create the database with Entity Framework Core migrations
  • MatPaginator & PageEvent: Custom Server-Side Paging
  • Unit Testing: Custom Server-Side Paging
  • Repository Pattern: VehicleRepository
  • Unit Test: Paging in the Vehicles controller
  • Server-Side Sorting
  • Unit Tests: Sorting
  • Filter (Quick Search)
  • Unit Tests: Filter feature
  • Advanced Search: Categories
  • Unit Tests: Search by category
  • Progress Spinner: Final Fix

TOC

  • What were WebForms?
  • Enter MVC
    • Understanding MVC
    • Advantages of MVC
  • ASP.Net Core MVC – A total rewrite
  • ASP.Net Core 2 MVC – Here come Razor Pages
    • Understanding Razor Pages
  • ASP.Net Core 3 – Dropping the MVC reference
    • Understanding Blazor
  • Dropping the MVC reference
  • Hello .Net 5!
  • What’s Next? – Here comes .Net 6.

Recent Posts

  • Angular Commands Cheat Sheet
  • Installing Git for Windows
  • Installing Postman
  • Installing SQL Server 2022 Express
  • Installing Visual Studio 2022

Recent Comments

No comments to show.

Archives

  • November 2023
  • October 2023
  • June 2023
  • October 2021

Categories

  • Angular
  • ASP.Net
  • Environment Setup
  • See All
  • SQL Server
  • Visual Studio
  • Web API & Rest Services

WordPress Theme Editor

Copyright © 2025 Web Development School.

Powered by PressBook Blog WordPress theme