my package.json file
{
"name": "projetobase",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve ",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^8.2.3",
"@angular/cdk": "^8.1.3",
"@angular/common": "^8.2.14",
"@angular/compiler": "~8.2.3",
"@angular/core": "^8.2.14",
"@angular/forms": "~8.2.3",
"@angular/material": "^8.1.3",
"@angular/platform-browser": "~8.2.3",
"@angular/platform-browser-dynamic": "~8.2.3",
"@angular/router": "~8.2.3",
"@ng-bootstrap/ng-bootstrap": "^5.1.1",
"@ngrx/devtools": "^1.4.0",
"@ngrx/store": "^8.6.0",
"@ngrx/store-devtools": "^8.6.0",
"@ngx-translate/core": "^11.0.1",
"@ngx-translate/http-loader": "^4.0.0",
"@sweetalert2/theme-dark": "^3.1.4",
"angular-hammer": "^2.2.0",
"angular-popper": "^2.0.1",
"angular2-text-mask": "^9.0.0",
"angular2-toaster": "^8.0.0",
"bootstrap": "^4.3.1",
"chart.js": "^2.8.0",
"compass-mixins": "^0.12.10",
"core-js": "^2.5.4",
"file-saver": "^2.0.2",
"highcharts": "^7.2.0",
"jquery": "^3.4.1",
"moment": "^2.25.3",
"ng2-charts": "^2.3.0",
"ngx-bootstrap": "^5.1.2",
"ngx-cookie-service": "^2.2.0",
"ngx-mask": "^8.1.5",
"ngx-material-timepicker": "^5.5.1",
"ngx-spinner": "^9.0.2",
"ngx-toastr": "^10.1.0",
"ngx-uploader": "^7.1.0",
"popper.js": "^1.15.0",
"rxjs": "~6.5.2",
"sweetalert2": "^8.19.0",
"tslib": "^1.9.0",
"vanilla-text-mask": "^5.1.1",
"xlsx": "^0.15.5",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.803.23",
"@angular/cli": "~8.3.0",
"@angular/compiler-cli": "~8.2.3",
"@angular/language-service": "~8.2.3",
"@fortawesome/fontawesome-free": "^5.10.2",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "^5.0.1",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.5.3"
}
}
ngOnInit
case of the entire component, because there I can hide the spinner at the end of the inner most subscribe()
function. All good. Now: There are many filter options on the page and some take quite a long time until the page fully shows the updates. There I've got problems, because I can't find a proper place to hide the spinner after showing it e.g. when the user clicks one of the filter buttons. Hints are welcome. Demo 1: Go to http://preview.owasp-juice.shop/#/score-board (spinner working on initialization) - Demo 2: On the page click any of the two "Hide/Show all" buttons to see how rendering takes long on "Show all" without a spinner. There I'd really like to add one but can't find the right hook to hide it. Any hint or help welcome! (If you send a PR with a working solution, I'll happily send you a Juice Shop sticker pack! :smile:)
ngx-spinner
first paste below script to your package.json:
"scripts": {
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
}
}
ngx-spinner
and check again
hi guys, any idea why spinner is not being hide on finalize?
a.component.ts
ngAfterViewInit() {
this.subscriptions.add(
this.organizationsService.organizations$
.pipe(
tap(() => {
this.spinnerService.showLoader();
}),
finalize(() => {
this.spinnerService.hideLoader();
}),
takeUntil(this.destroySubject))
.subscribe(response => {
this.cachedFacts = this.cachedFacts.concat(response);
if (!this.searchService.search.value.length) {
this.dataSource.data = this.cachedFacts as IOrganizations[];
this.dataSource.sort = this.sort;
} else {
this.dataSource.data = response as IOrganizations[];
this.cachedFacts = [];
}
this.filterSelectObj.filter((o) => {
o.options = this.getFilterObject(this.dataSource.data, o.columnProp);
});
}, (error) => {
this.errorService.handleError(error);
})
);
}
spinner.service.ts
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { NgxSpinnerService } from 'ngx-spinner';
@Injectable()
export class SpinnerService {
constructor(private spinnerService: NgxSpinnerService) { }
public showLoaderSubject = new BehaviorSubject<boolean>(false);
showLoader() {
// this.showLoaderSubject.next(true);
this.spinnerService.show();
}
hideLoader() {
// this.showLoaderSubject.next(false);
this.spinnerService.hide();
}
}
spinner.module.ts
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SpinnerComponent } from './spinner.component';
import { NgxSpinnerModule, NgxSpinnerService } from 'ngx-spinner';
import { SpinnerService } from '@shared/services/spinner.service';
@NgModule({
imports: [
CommonModule,
NgxSpinnerModule
],
declarations: [SpinnerComponent],
exports: [SpinnerComponent],
providers: [SpinnerService, NgxSpinnerService]
})
export class SpinnerModule { }