This article is a mirror article of machine translation, please click here to jump to the original article.

View: 2834|Reply: 0

[Angular] Angular 17 Series (XIX) Globally Set HTTP Request Loading Animations

[Copy link]
Posted on 6/10/2024 3:09:56 PM | | | |
Requirements: HTTP requests are a very time-consuming process, when a user submits a form on the frontend, the backend needs various checks and then a persistent database, and the data is transmitted over the network. When a user submits a form, weYou don't want the user to be able to click on any action on the interface (or you don't want to repeatedly click Submit)。 We need an animation for global loading.

ng-http-loader This package provides an HTTP blocker and some spinner components (all from SpinKit for now). The HTTP blocker listens for all HTTP requests and displays a rotator/loader indicator during pending HTTP requests.

NPM address:The hyperlink login is visible.
GitHub address:The hyperlink login is visible.

Install the appropriate ng-http-loader version according to your Angular version, taking the Angular 17 version as an example, the installation command is as follows:



Since I am a standalone component, I modified app.config.ts as follows:

Meanwhile, the app.component.ts component is modified as follows:

Finally, modify the app.component.html code as follows:

The renderings are as follows:



For information on loading animation style effects, please refer to the following:

export const Spinkit = {
    skChasingDots: 'sk-chasing-dots',
    skCubeGrid: 'sk-cube-grid',
    skDoubleBounce: 'sk-double-bounce',
    skRotatingPlane: 'sk-rotationg-plane',
    skSpinnerPulse: 'sk-spinner-pulse',
    skThreeBounce: 'sk-three-bounce',
    skWanderingCubes: 'sk-wandering-cubes',
    skWave: 'sk-wave'
};
(End)





Previous:Angular 17 series (eighteen) ForkJoin waits for multiple HTTP parallel requests
Next:C#/.NET uses SequenceEqual to compare whether two sets are equal
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com