Router Data Resolver / Download Indicator from Angular 4? Can it be played in Ionic 3

I saw in Angular 4 that you are using a Router Data Resolver, and you have a download indicator, so you won’t scroll through the screen when all the data is not loaded.
See the relevant partial code snippets below:
What is the Ionic 3 method?
I am trying to use a data table from PrimeNg in my application, and the pagination tab first displays one, and then after a few seconds switches to loading the first page. So I would like to do something similar to what I saw in Angular ...

app.module.ts

import {RouterModule} from '@angular/router'; import {routerConfig} from "./router.config"; @NgModule({ imports: [ RouterModule.forRoot(routerConfig) ] }) 

router.config.ts

 export const routerConfig: Routes = [ path: 'test/:id' component: DataComponent resolve: { key: DataComponentResolver } ]; 

data-component-resolver.ts

 import { Injectable } from '@angular/core'; import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { Observable } from 'rxjs'; @Injectable() export class DataComponentResolver implements Resolve<[Data[]]> { constructor(private dataService: DataService) { } resolve( route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<[Data[]]> { return this.dataService.findData(route.params['id']); } } 

date-component.ts

 import {Component, OnInit} from '@angular/core'; @Component({ selector: 'data', templateUrl: './data.component.html' }) export class DataComponent implements OnInit{ $data: Observable<Data[]>; constructor(private route:ActivatedRoute) {} ngOnInit() { this.data$ = this.route.data.map(data => data['key']); //from router.config.ts } 

load-component.html

 <div *NgIf="isLoading$ | async" class="load-ind"> <img src="./images/spinning-cog.gif"/> </div> 

Loading-component.ts

 export class LoadingComponent implements OnInit{ isLoading$: Observable<boolean> constructor(private router: Router){ } ngInit() { this.isLoading$ = this.router.events .map(event => event instanceof NavigationStart || event instanceof RoutesRecognised); } } 

app.component.html

 <loading></loading> <div> <router-outlet></router-outlet> </div> 
+1
ionic3
source share

No one has answered this question yet.

See similar questions:

8
Angular2 -router: how to change route parameter only?
0
Show progress while data is loading in the corner application4
0
Get data from Firebase in descending order
-2
Div with ng-repeat flickers once on page load

or similar:

4
ionic3, differences between NavController and Nav, from the 'ionic-angular' package
one
Ion 3 Receiver load on the corner component
one
Ionic 3 + Angular 4 + chart.js - loading data from an array
one
How to implement animation of a corner router in Ionic 3?
0
The ion page does not transfer data from the transcript to HTML
0
Apply lazy loading for dynamic data to load first and then static data in Ionic
0
ionic 3 cannot pull data from the database
0
ion angular data binding error
0
Loading data from mysql to Ionic
0
Angular 5 (ionic) JSONP request

All Articles