Unable to show spinner or loading… in Angular 6 while using *ngIfAngular dynamic tabs with user-click chosen componentsAngular 2 load child component on clickAngular - Animation initialization with ngIfAngular 2 & 4: NgIf/else condition for showing directives on window loadAngular2 router appends component instead of replacing itshow loading while changing content using ngif elseAngular 6 - Waiting for element to load inside *ngIf on setting ngIf to trueAvoid delay when using `*ngIf` in AngularUnable to load data inside ngOnInitAngular - Lazy loading a module inside module with a child route
Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?
Creepy dinosaur pc game identification
A social experiment. What is the worst that can happen?
How to fade a semiplane defined by line?
Quoting Keynes in a lecture
Keeping a ball lost forever
What does "Scientists rise up against statistical significance" mean? (Comment in Nature)
Recommended PCB layout understanding - ADM2572 datasheet
Are Captain Marvel's powers affected by Thanos' actions in Infinity War
How to explain what's wrong with this application of the chain rule?
Is there a RAID 0 Equivalent for RAM?
How does a computer interpret real numbers?
Why Shazam when there is already Superman?
Calculating total slots
Is there a way to get `mathscr' with lower case letters in pdfLaTeX?
Does malloc reserve more space while allocating memory?
What is Cash Advance APR?
Limits and Infinite Integration by Parts
Terse Method to Swap Lowest for Highest?
Can I say "fingers" when referring to toes?
When were female captains banned from Starfleet?
15% tax on $7.5k earnings. Is that right?
Does the UK parliament need to pass secondary legislation to accept the Article 50 extension
How to rewrite equation of hyperbola in standard form
Unable to show spinner or loading… in Angular 6 while using *ngIf
Angular dynamic tabs with user-click chosen componentsAngular 2 load child component on clickAngular - Animation initialization with ngIfAngular 2 & 4: NgIf/else condition for showing directives on window loadAngular2 router appends component instead of replacing itshow loading while changing content using ngif elseAngular 6 - Waiting for element to load inside *ngIf on setting ngIf to trueAvoid delay when using `*ngIf` in AngularUnable to load data inside ngOnInitAngular - Lazy loading a module inside module with a child route
I have 4 buttons like tabs, when I click on first button I have to render first component, if click on second button then second component like so..
Now my problem is when I am switching/clicking one button to another components takes too much time to render DOM so that I want to display "Loading.....".
angular angular-material
add a comment |
I have 4 buttons like tabs, when I click on first button I have to render first component, if click on second button then second component like so..
Now my problem is when I am switching/clicking one button to another components takes too much time to render DOM so that I want to display "Loading.....".
angular angular-material
add any third party loader. it will work
– shubham chhapre
Mar 7 at 6:36
is your component waiting for retrieving some data from server then you can use npmjs.com/package/ng-http-loader
– Joel Joseph
Mar 7 at 6:36
By unable to show spinner or loading what do you mean? They don't appear at all or what happens? Also if you can add some code it will be helpful.
– emkay
Mar 7 at 6:43
you have to use mat-spinner for show loading and use this in ngIf is like: *ngIf="data; else loading_template".
– sahil0021
Mar 7 at 6:54
add a comment |
I have 4 buttons like tabs, when I click on first button I have to render first component, if click on second button then second component like so..
Now my problem is when I am switching/clicking one button to another components takes too much time to render DOM so that I want to display "Loading.....".
angular angular-material
I have 4 buttons like tabs, when I click on first button I have to render first component, if click on second button then second component like so..
Now my problem is when I am switching/clicking one button to another components takes too much time to render DOM so that I want to display "Loading.....".
angular angular-material
angular angular-material
asked Mar 7 at 6:27
Venkatesh KalisettyVenkatesh Kalisetty
103
103
add any third party loader. it will work
– shubham chhapre
Mar 7 at 6:36
is your component waiting for retrieving some data from server then you can use npmjs.com/package/ng-http-loader
– Joel Joseph
Mar 7 at 6:36
By unable to show spinner or loading what do you mean? They don't appear at all or what happens? Also if you can add some code it will be helpful.
– emkay
Mar 7 at 6:43
you have to use mat-spinner for show loading and use this in ngIf is like: *ngIf="data; else loading_template".
– sahil0021
Mar 7 at 6:54
add a comment |
add any third party loader. it will work
– shubham chhapre
Mar 7 at 6:36
is your component waiting for retrieving some data from server then you can use npmjs.com/package/ng-http-loader
– Joel Joseph
Mar 7 at 6:36
By unable to show spinner or loading what do you mean? They don't appear at all or what happens? Also if you can add some code it will be helpful.
– emkay
Mar 7 at 6:43
you have to use mat-spinner for show loading and use this in ngIf is like: *ngIf="data; else loading_template".
– sahil0021
Mar 7 at 6:54
add any third party loader. it will work
– shubham chhapre
Mar 7 at 6:36
add any third party loader. it will work
– shubham chhapre
Mar 7 at 6:36
is your component waiting for retrieving some data from server then you can use npmjs.com/package/ng-http-loader
– Joel Joseph
Mar 7 at 6:36
is your component waiting for retrieving some data from server then you can use npmjs.com/package/ng-http-loader
– Joel Joseph
Mar 7 at 6:36
By unable to show spinner or loading what do you mean? They don't appear at all or what happens? Also if you can add some code it will be helpful.
– emkay
Mar 7 at 6:43
By unable to show spinner or loading what do you mean? They don't appear at all or what happens? Also if you can add some code it will be helpful.
– emkay
Mar 7 at 6:43
you have to use mat-spinner for show loading and use this in ngIf is like: *ngIf="data; else loading_template".
– sahil0021
Mar 7 at 6:54
you have to use mat-spinner for show loading and use this in ngIf is like: *ngIf="data; else loading_template".
– sahil0021
Mar 7 at 6:54
add a comment |
2 Answers
2
active
oldest
votes
If you just wish to show Loading ..., then modify the index.html
to look like this:
<app-root>
Loading ...
</app-root>
If you want a pure CSS Loader, modify the index.html
to look like this:
<body>
<app-root>
<div class="loader">Loading ...</div>
</app-root>
</body>
And now animate the .loader
class as per your preference. You can play with the Plunker that I have created here: http://next.plnkr.co/edit/Ox5uJGpDSkMYQ9Fp
add a comment |
If every component has it's own route then you can subscribe to Router.
In app.component.ts
import Router, Event as RouterEvent, NavigationStart, NavigationEnd, NavigationCancel, NavigationError from '@angular/router';
constructor(private router: Router)
this.router.events.subscribe((event: RouterEvent) =>
this.navigationInterceptor(event)
);
navigationInterceptor(event: RouterEvent): void
if (event instanceof NavigationStart)
this.loading = true
if (event instanceof NavigationEnd)
this.loading = false
// Set loading state to false in both of the below events to hide the spinner in case a request fails
if (event instanceof NavigationCancel)
this.loading = false
if (event instanceof NavigationError)
this.loading = false
In app.component.html
<router-outlet></router-outlet>
<spinner-component [spinnerShow]="loading_data"></spinner-component>
Spinner.component.ts
import Component, Input from '@angular/core';
@Component(
selector: 'spinner-component',
templateUrl: './spinner.component.html',
styleUrls: ["./spinner.component.scss"]
)
export class SpinnerComponent
@Input() spinnerShow: boolean;
Spinner.component.html
<div *ngIf="spinnerShow" class="sc-background"></div>
<div *ngIf="spinnerShow" [ngClass]="'sc-default-spinner' : ref.children.length == 0 " class="logo sc-center">
<div #ref><ng-content></ng-content></div></div>
Spinner.component.scss
.sc-background
content : "";
z-index: 1004;
position: absolute;
top:-10%;
right:0;
left:0;
bottom: 0;
background-color: rgba(255,255,255,0.8);
.logo
background: url("./../../../../assets/images/sprite/template.png") 0px 0px;
width:30px;
.sc-center
top: 50vh;
margin: auto;
position: fixed;
left: 0;
right: 0;
z-index: 1005;
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037352%2funable-to-show-spinner-or-loading-in-angular-6-while-using-ngif%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you just wish to show Loading ..., then modify the index.html
to look like this:
<app-root>
Loading ...
</app-root>
If you want a pure CSS Loader, modify the index.html
to look like this:
<body>
<app-root>
<div class="loader">Loading ...</div>
</app-root>
</body>
And now animate the .loader
class as per your preference. You can play with the Plunker that I have created here: http://next.plnkr.co/edit/Ox5uJGpDSkMYQ9Fp
add a comment |
If you just wish to show Loading ..., then modify the index.html
to look like this:
<app-root>
Loading ...
</app-root>
If you want a pure CSS Loader, modify the index.html
to look like this:
<body>
<app-root>
<div class="loader">Loading ...</div>
</app-root>
</body>
And now animate the .loader
class as per your preference. You can play with the Plunker that I have created here: http://next.plnkr.co/edit/Ox5uJGpDSkMYQ9Fp
add a comment |
If you just wish to show Loading ..., then modify the index.html
to look like this:
<app-root>
Loading ...
</app-root>
If you want a pure CSS Loader, modify the index.html
to look like this:
<body>
<app-root>
<div class="loader">Loading ...</div>
</app-root>
</body>
And now animate the .loader
class as per your preference. You can play with the Plunker that I have created here: http://next.plnkr.co/edit/Ox5uJGpDSkMYQ9Fp
If you just wish to show Loading ..., then modify the index.html
to look like this:
<app-root>
Loading ...
</app-root>
If you want a pure CSS Loader, modify the index.html
to look like this:
<body>
<app-root>
<div class="loader">Loading ...</div>
</app-root>
</body>
And now animate the .loader
class as per your preference. You can play with the Plunker that I have created here: http://next.plnkr.co/edit/Ox5uJGpDSkMYQ9Fp
answered Mar 7 at 7:00
retr0retr0
12911
12911
add a comment |
add a comment |
If every component has it's own route then you can subscribe to Router.
In app.component.ts
import Router, Event as RouterEvent, NavigationStart, NavigationEnd, NavigationCancel, NavigationError from '@angular/router';
constructor(private router: Router)
this.router.events.subscribe((event: RouterEvent) =>
this.navigationInterceptor(event)
);
navigationInterceptor(event: RouterEvent): void
if (event instanceof NavigationStart)
this.loading = true
if (event instanceof NavigationEnd)
this.loading = false
// Set loading state to false in both of the below events to hide the spinner in case a request fails
if (event instanceof NavigationCancel)
this.loading = false
if (event instanceof NavigationError)
this.loading = false
In app.component.html
<router-outlet></router-outlet>
<spinner-component [spinnerShow]="loading_data"></spinner-component>
Spinner.component.ts
import Component, Input from '@angular/core';
@Component(
selector: 'spinner-component',
templateUrl: './spinner.component.html',
styleUrls: ["./spinner.component.scss"]
)
export class SpinnerComponent
@Input() spinnerShow: boolean;
Spinner.component.html
<div *ngIf="spinnerShow" class="sc-background"></div>
<div *ngIf="spinnerShow" [ngClass]="'sc-default-spinner' : ref.children.length == 0 " class="logo sc-center">
<div #ref><ng-content></ng-content></div></div>
Spinner.component.scss
.sc-background
content : "";
z-index: 1004;
position: absolute;
top:-10%;
right:0;
left:0;
bottom: 0;
background-color: rgba(255,255,255,0.8);
.logo
background: url("./../../../../assets/images/sprite/template.png") 0px 0px;
width:30px;
.sc-center
top: 50vh;
margin: auto;
position: fixed;
left: 0;
right: 0;
z-index: 1005;
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
add a comment |
If every component has it's own route then you can subscribe to Router.
In app.component.ts
import Router, Event as RouterEvent, NavigationStart, NavigationEnd, NavigationCancel, NavigationError from '@angular/router';
constructor(private router: Router)
this.router.events.subscribe((event: RouterEvent) =>
this.navigationInterceptor(event)
);
navigationInterceptor(event: RouterEvent): void
if (event instanceof NavigationStart)
this.loading = true
if (event instanceof NavigationEnd)
this.loading = false
// Set loading state to false in both of the below events to hide the spinner in case a request fails
if (event instanceof NavigationCancel)
this.loading = false
if (event instanceof NavigationError)
this.loading = false
In app.component.html
<router-outlet></router-outlet>
<spinner-component [spinnerShow]="loading_data"></spinner-component>
Spinner.component.ts
import Component, Input from '@angular/core';
@Component(
selector: 'spinner-component',
templateUrl: './spinner.component.html',
styleUrls: ["./spinner.component.scss"]
)
export class SpinnerComponent
@Input() spinnerShow: boolean;
Spinner.component.html
<div *ngIf="spinnerShow" class="sc-background"></div>
<div *ngIf="spinnerShow" [ngClass]="'sc-default-spinner' : ref.children.length == 0 " class="logo sc-center">
<div #ref><ng-content></ng-content></div></div>
Spinner.component.scss
.sc-background
content : "";
z-index: 1004;
position: absolute;
top:-10%;
right:0;
left:0;
bottom: 0;
background-color: rgba(255,255,255,0.8);
.logo
background: url("./../../../../assets/images/sprite/template.png") 0px 0px;
width:30px;
.sc-center
top: 50vh;
margin: auto;
position: fixed;
left: 0;
right: 0;
z-index: 1005;
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
add a comment |
If every component has it's own route then you can subscribe to Router.
In app.component.ts
import Router, Event as RouterEvent, NavigationStart, NavigationEnd, NavigationCancel, NavigationError from '@angular/router';
constructor(private router: Router)
this.router.events.subscribe((event: RouterEvent) =>
this.navigationInterceptor(event)
);
navigationInterceptor(event: RouterEvent): void
if (event instanceof NavigationStart)
this.loading = true
if (event instanceof NavigationEnd)
this.loading = false
// Set loading state to false in both of the below events to hide the spinner in case a request fails
if (event instanceof NavigationCancel)
this.loading = false
if (event instanceof NavigationError)
this.loading = false
In app.component.html
<router-outlet></router-outlet>
<spinner-component [spinnerShow]="loading_data"></spinner-component>
Spinner.component.ts
import Component, Input from '@angular/core';
@Component(
selector: 'spinner-component',
templateUrl: './spinner.component.html',
styleUrls: ["./spinner.component.scss"]
)
export class SpinnerComponent
@Input() spinnerShow: boolean;
Spinner.component.html
<div *ngIf="spinnerShow" class="sc-background"></div>
<div *ngIf="spinnerShow" [ngClass]="'sc-default-spinner' : ref.children.length == 0 " class="logo sc-center">
<div #ref><ng-content></ng-content></div></div>
Spinner.component.scss
.sc-background
content : "";
z-index: 1004;
position: absolute;
top:-10%;
right:0;
left:0;
bottom: 0;
background-color: rgba(255,255,255,0.8);
.logo
background: url("./../../../../assets/images/sprite/template.png") 0px 0px;
width:30px;
.sc-center
top: 50vh;
margin: auto;
position: fixed;
left: 0;
right: 0;
z-index: 1005;
If every component has it's own route then you can subscribe to Router.
In app.component.ts
import Router, Event as RouterEvent, NavigationStart, NavigationEnd, NavigationCancel, NavigationError from '@angular/router';
constructor(private router: Router)
this.router.events.subscribe((event: RouterEvent) =>
this.navigationInterceptor(event)
);
navigationInterceptor(event: RouterEvent): void
if (event instanceof NavigationStart)
this.loading = true
if (event instanceof NavigationEnd)
this.loading = false
// Set loading state to false in both of the below events to hide the spinner in case a request fails
if (event instanceof NavigationCancel)
this.loading = false
if (event instanceof NavigationError)
this.loading = false
In app.component.html
<router-outlet></router-outlet>
<spinner-component [spinnerShow]="loading_data"></spinner-component>
Spinner.component.ts
import Component, Input from '@angular/core';
@Component(
selector: 'spinner-component',
templateUrl: './spinner.component.html',
styleUrls: ["./spinner.component.scss"]
)
export class SpinnerComponent
@Input() spinnerShow: boolean;
Spinner.component.html
<div *ngIf="spinnerShow" class="sc-background"></div>
<div *ngIf="spinnerShow" [ngClass]="'sc-default-spinner' : ref.children.length == 0 " class="logo sc-center">
<div #ref><ng-content></ng-content></div></div>
Spinner.component.scss
.sc-background
content : "";
z-index: 1004;
position: absolute;
top:-10%;
right:0;
left:0;
bottom: 0;
background-color: rgba(255,255,255,0.8);
.logo
background: url("./../../../../assets/images/sprite/template.png") 0px 0px;
width:30px;
.sc-center
top: 50vh;
margin: auto;
position: fixed;
left: 0;
right: 0;
z-index: 1005;
edited Mar 7 at 7:01
answered Mar 7 at 6:51
Eeshwar AnkathiEeshwar Ankathi
666
666
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
add a comment |
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
could you please show me your component spinner-component?
– shubham chhapre
Mar 7 at 6:55
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55037352%2funable-to-show-spinner-or-loading-in-angular-6-while-using-ngif%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
add any third party loader. it will work
– shubham chhapre
Mar 7 at 6:36
is your component waiting for retrieving some data from server then you can use npmjs.com/package/ng-http-loader
– Joel Joseph
Mar 7 at 6:36
By unable to show spinner or loading what do you mean? They don't appear at all or what happens? Also if you can add some code it will be helpful.
– emkay
Mar 7 at 6:43
you have to use mat-spinner for show loading and use this in ngIf is like: *ngIf="data; else loading_template".
– sahil0021
Mar 7 at 6:54