Skip to content

Commit 29d9db8

Browse files
authored
Merge pull request #69 from raj-rathod/rajesh
Rajesh
2 parents c055023 + 12b035f commit 29d9db8

26 files changed

+689
-816
lines changed

src/app/components/NonprimitiveData/linear/arrays/array/array.component.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ <h1 class="text-center">Array</h1>
66
<div class="mt-md-4 mt-3">
77
<div class="row">
88
<div class="col-6 pe-0">
9-
<div class="btn-bg p-lg-3 p-2 rounded-start tab arraytab " (click)="tabChange(0)">
9+
<div [class]=" state === 0 ? 'btn-bg p-lg-3 p-2 rounded-start tab':'btn-bg-unactive p-lg-3 p-2 rounded-start tab'"
10+
(click)="tabChange(0)">
1011
<p class='text-center m-0'>1D-Array</p>
1112
</div>
1213
</div>
1314
<div class="col-6 ps-0">
14-
<div class="btn-bg-unactive p-lg-3 p-2 rounded-end tab arraytab" (click)="tabChange(1)">
15+
<div [class]=" state === 1 ? 'btn-bg p-lg-3 p-2 rounded-end tab':'btn-bg-unactive p-lg-3 p-2 rounded-end tab'" (click)="tabChange(1)">
1516
<p class='text-center m-0'>2D-Array</p>
1617
</div>
1718
</div>
1819
</div>
1920
</div>
2021
<div class="my-4">
21-
<router-outlet></router-outlet>
22+
<ng-container *ngIf="state === 0">
23+
<app-one-dimension></app-one-dimension>
24+
</ng-container>
25+
<ng-container *ngIf="state === 1">
26+
<app-two-dimension></app-two-dimension>
27+
</ng-container>
2228
</div>
2329
<div class="mt-md-4 mt-3" [innerHtml]="arrayMetaData.algorithms"></div>
2430
<div class="mt-md-4 mt-3" [innerHtml]="arrayMetaData.applications"></div>
Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,22 @@
1-
import { AfterViewInit, Component, ElementRef, OnInit } from '@angular/core';
2-
import { Router } from '@angular/router';
1+
import { Component, OnInit } from '@angular/core';
32
import { arrayData } from 'src/app/core/data-structures/linear/array/array-meta-data';
43

54
@Component({
65
selector: 'app-array',
76
templateUrl: './array.component.html',
87
styleUrls: ['./array.component.css']
98
})
10-
export class ArrayComponent implements OnInit, AfterViewInit {
9+
export class ArrayComponent implements OnInit {
1110
state = 0;
1211
arrayMetaData = arrayData;
1312
constructor(
14-
private router: Router,
15-
private elRef: ElementRef
1613
) { }
1714

1815
ngOnInit(): void {
19-
if(this.router.routerState.snapshot.url.split('/')[4] === 'two-dimension'){
20-
this.state = 1;
21-
}else{
22-
this.state = 0;
23-
}
24-
}
25-
ngAfterViewInit(): void {
26-
this.tabChange(this.state);
16+
2717
}
2818
tabChange(index: number): void {
29-
const tabRef = this.elRef.nativeElement.querySelectorAll('.arraytab');
30-
for (let i = 0; i < tabRef.length; i++) {
31-
if(index === i){
32-
if(index === 0){
33-
tabRef[i].className = 'btn-bg p-lg-3 p-2 rounded-start tab arraytab';
34-
this.router.navigate(['/non-primitive/linear/array/one-dimension']);
35-
}else{
36-
tabRef[i].className = 'btn-bg p-lg-3 p-2 rounded-end tab arraytab';
37-
this.router.navigate(['/non-primitive/linear/array/two-dimension']);
38-
}
39-
}else{
40-
if(index !== 0){
41-
tabRef[i].className = 'btn-bg-unactive p-lg-3 p-2 rounded-start tab arraytab';
42-
}else{
43-
tabRef[i].className = 'btn-bg-unactive p-lg-3 p-2 rounded-end tab arraytab';
44-
}
45-
}
46-
}
19+
this.state = index;
4720
}
4821

4922
}

0 commit comments

Comments
 (0)