Commit 8c28948b authored by Anusha Mamidala's avatar Anusha Mamidala
Browse files

fixed routing issues

parent 6d5b580c
......@@ -10,13 +10,10 @@ const routes: Routes = [
path: 'home', component: HomeComponent
},
{
path: 'home/:subject', component: SimulationsComponent
},
{
path: 'videos', component: SimulationsComponent,
path: 'videos/:simUrl', component: VideoSimulationComponent,
},
{
path: 'videos/:simUrl', component: VideoSimulationComponent,
path: 'home/:subject', component: SimulationsComponent
}
];
......
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { CourseService } from 'src/app/services/course.service';
import { Course } from 'src/app/shared/course';
......@@ -24,7 +24,7 @@ export class HomeComponent implements OnInit {
mathsItems: Course[];
biologyItems: Course[];
constructor(private router: Router, private service: CourseService) { }
constructor(private router: Router, private service: CourseService, private route: ActivatedRoute) { }
ngOnInit(): void {
this.service.getJSON().subscribe((response: any) => {
......@@ -83,7 +83,7 @@ export class HomeComponent implements OnInit {
onClickSubject(i) {
this.selectedOption = {
"selectedClass": "",
"selectedSubject":i.type
"selectedSubject": i.type
}
this.simulationItems = this.filterSubjectsClasses();
}
......
......@@ -23,6 +23,11 @@ export class SimulationsComponent implements OnInit {
}
onClickSimulation(item) {
this.router.navigate(['/videos', item.url]);
if (this.subject && this.subject != "") {
this.router.navigate(['../../videos', item.url], { relativeTo: this.route });
}
else {
this.router.navigate(['../videos', item.url], { relativeTo: this.route });
}
}
}
......@@ -12,7 +12,7 @@ export class VideoSimulationComponent implements OnInit {
ngOnInit(): void {
let id = this.route.snapshot.paramMap.get('simUrl');
this.item = "../assets/simulation-files" + id + ".html";
this.item = "../assets/simulation-files/" + id + ".html";
console.log(this.item)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment