This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
exercise.route.ts 938 B
Newer Older
Michael Breu's avatar
Michael Breu committed
import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { Observable, of } from 'rxjs';
import { ExerciseComponent } from './exercise.component';

@Injectable({ providedIn: 'root' })
export class ExerciseResolve implements Resolve<String> {
  resolve(route: ActivatedRouteSnapshot): Observable<String> | Observable<never> {
    let subUrl = '';
Michael Breu's avatar
Michael Breu committed
    for (let i = 0; i < route.url.length; i++) {
Michael Breu's avatar
Michael Breu committed
      subUrl += route.url[i].path;
Michael Breu's avatar
Michael Breu committed
    }
    if (subUrl === '') return of('');
Michael Breu's avatar
Michael Breu committed
    return of(subUrl);
  }
}

export const exerciseRoutes = {
Michael Breu's avatar
Michael Breu committed
  path: 'item',
Michael Breu's avatar
Michael Breu committed
  children: [
    {
      path: '**',
      loadChildren: () => import('app/exercisePage/exercisePages.module').then(m => m.ExercisePageModule),
      resolve: {
        pagePath: ExerciseResolve,
      },
      component: ExerciseComponent,
    },
  ],
};