Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. import { NgModule } from '@angular/core';
  2. import { Routes, RouterModule } from '@angular/router';
  3.  
  4. import { StartGameComponent } from './start-game/start-game.component';
  5. import { GameComponent } from './game/game.component';
  6.  
  7.  
  8. const appRoutes: Routes = [
  9. { path: '', redirectTo: '/first', pathMatch: 'full' },
  10. { path: 'startGame', component: StartGameComponent },
  11. {path: 'game/:width/:height',component: GameComponent
  12. }
  13.  
  14. ];
  15.  
  16. @NgModule({
  17. imports: [RouterModule.forRoot(appRoutes)],
  18. exports: [RouterModule]
  19. })
  20. export class AppRoutingModule {
  21.  
  22. }
  23.  
  24. goToGameComponent(width:string,height:string){
  25. this.router.navigate(['game', {width:width,height:height}]);
  26. }
  27.  
  28. ngOnInit() {
  29. this.route.params.forEach((urlParams) => {
  30. this.width= urlParams['width'];
  31. this.height=urlParams['height'];
  32.  
  33. });
  34.  
  35. <div>
  36. <md-toolbar color="primary">
  37. <span>MineSweeper Wix</span>
  38.  
  39. </md-toolbar>
  40. <router-outlet></router-outlet>
  41.  
  42. <span class="done">
  43. <button md-fab>
  44. <md-icon>check circle</md-icon>
  45. </button>
  46. </span>
  47. </div>
  48.  
  49. this.router.navigate([], { relativeTo: this.activatedRoute, queryParams });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement