Angular - What's the best way to include html in multiple components?

Pedro Relvas

I need to put a loading in multiple components of my project. So instead of putting the same HTML over and over again across the components, I need to know what's the best way to not repeat code, but I don't know if this is correct thing to do. I have created a component called loading-graphic, which I bind it in every HTML file of the respective components. I read about ngTemplateOutlet and ngContent, but to be honest it doesn't make sense in my head to use it for this case (and I don't get it too... I'm a beginner on it). So, on what should I bet? Thanks.

dfil

i think loading component is not a bad Idee. Use loading component in your app-root component. You can use a loading.service and interceptor to display or hide the component. You will get automatically a Loading Indicator for each API call.

sample: https://medium.com/@zeljkoradic/loader-bar-on-every-http-request-in-angular-6-60d8572a21a9

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

what is best way to reuse components in multiple projects in angular?

importing sass variables file in Angular components, what's the best way?

What is the best way working multiple projects with angular?

What is the best way to post form with multiple components using Vue js

What's the best way to handle multiple SKScenes?

What is the best way to manage and include multiple files using Go?

What is the best way to include babel polyfill using multiple entry points

The best way to share WebSocket data between multiple components in Angular 2?

what's the best way to share user data between components?

What's the best way to explicitly include types in tsconfig?

What is the best way to include css files for Prime React components when using Parceljs?

What’s the best way to build components based on other, smaller base components?

What is the best way to code HTML table with multiple headers in between rows?

What's the most performatic way to import components and modules in Angular?

What's the best way to compress multiple values into deserializable value?

R What's the best way to transform multiple variables?

What's the best way to place multiple images onto the screen simultaneously?

What's the best way to share JARs across multiple projects?

What's the best way to return multiple values from a function in Python?

What's the best way to create a .cab file of multiple files quickly?

What's the best way to improve time complexity with multiple FOR loops

What's the best way to share a dbcontext between multiple services?

What's the best way to have a website with multiple languages?

What's the best way to search and replace all for multiple terms?

What's the best way to make multiple draggable views programmatically?

What's the best way to return multiple values in a promise chain

What's the best way to have multiple "setTimeout" in jQuery?

What's the best way to send multiple requests to a server?

What's the best way to show multiple static images in a React app?