import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';

import { SharedModule } from '../shared/shared.module';

import { AlbumComponent } from './album/album.component';
import { AlbumListComponent } from './album-list/album-list.component';
import { ImageComponent } from './image/image.component';
import { ImageContainerComponent } from './image-container/image-container.component';
import { ThumbnailComponent } from './thumbnail/thumbnail.component';

import { ImageService } from './image.service';
import { AlbumService } from './album.service';

import { GalleryFormatPipe } from './gallery-format.pipe';

const galleryRoutes: Routes = [
  {path: '', component: AlbumComponent, pathMatch: 'full' },
  {path: 'albums', component: AlbumListComponent },
  {path: 'album/:name', component: AlbumComponent },
  {path: 'album/:name/page/:page', component: AlbumComponent },
  {path: 'view/:id', component: ImageComponent },
];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(galleryRoutes),
    SharedModule
  ],
  declarations: [AlbumComponent, AlbumListComponent, GalleryFormatPipe, ImageComponent, ImageContainerComponent, ThumbnailComponent],
  exports: [ImageContainerComponent],
  providers: [ImageService, AlbumService]
})
export class GalleryModule { }

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';

import { SharedModule } from '../shared/shared.module';

import { AlbumComponent } from './album/album.component';
import { AlbumListComponent } from './album-list/album-list.component';
import { ImageComponent } from './image/image.component';
import { ImageContainerComponent } from './image-container/image-container.component';
import { ThumbnailComponent } from './thumbnail/thumbnail.component';

import { ImageService } from './image.service';
import { AlbumService } from './album.service';

import { GalleryFormatPipe } from './gallery-format.pipe';

const galleryRoutes: Routes = [
  {path: '', component: AlbumComponent, pathMatch: 'full' },
  {path: 'albums', component: AlbumListComponent },
  {path: 'album/:name/page/:page', component: AlbumComponent },
  {path: 'album/:name', component: AlbumComponent },
  {path: 'view/:id', component: ImageComponent },
];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forChild(galleryRoutes),
    SharedModule
  ],
  declarations: [AlbumComponent, AlbumListComponent, GalleryFormatPipe, ImageComponent, ImageContainerComponent, ThumbnailComponent],
  exports: [ImageContainerComponent],
  providers: [ImageService, AlbumService]
})
export class GalleryModule { }

Fix issue with gallery album component
Fix issue with gallery album component

Having these `album/:name` route before the `album/:name/page/:pagenumber` caused Angular to throw an error in some cases.