Skip to content

Commit

Permalink
routing
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-alibou authored and ali-bouali committed Feb 20, 2023
1 parent dbfbcb1 commit 2dd664a
Show file tree
Hide file tree
Showing 16 changed files with 140 additions and 5 deletions.
18 changes: 17 additions & 1 deletion frontend/angular/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { Page1Component } from './pages/page1/page1.component';
import { Page2Component } from './pages/page2/page2.component';
import { Page3Component } from './pages/page3/page3.component';

const routes: Routes = [];
const routes: Routes = [
{
path: 'page-1',
component: Page1Component
},
{
path: 'page-2',
component: Page2Component
},
{
path: 'page-3',
component: Page3Component
}
];

@NgModule({
imports: [RouterModule.forRoot(routes)],
Expand Down
8 changes: 5 additions & 3 deletions frontend/angular/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<h1>Hello Angular!</h1>

<app-my-first-component></app-my-first-component>
<div>
<a routerLink="/page-1">Page 1</a>&nbsp;|&nbsp;
<a routerLink="/page-2">Page 2</a>&nbsp;|&nbsp;
<a (click)="navigateToPage3()" href="javascript:void(0);">Page 3</a>
</div>

<router-outlet></router-outlet>
9 changes: 9 additions & 0 deletions frontend/angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';

@Component({
selector: 'app-root',
Expand All @@ -7,4 +8,12 @@ import { Component } from '@angular/core';
})
export class AppComponent {
title = 'angular';

constructor(
private router: Router
) {}

navigateToPage3() {
this.router.navigate(['page-3']);
}
}
8 changes: 7 additions & 1 deletion frontend/angular/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import { AppComponent } from './app.component';
import { MyFirstComponent } from './my-first-component/my-first.component';
import { FormsModule } from '@angular/forms';
import { MyCalculatorService } from './services/my-calculator.service';
import { Page1Component } from './pages/page1/page1.component';
import { Page2Component } from './pages/page2/page2.component';
import { Page3Component } from './pages/page3/page3.component';

@NgModule({
declarations: [
AppComponent,
MyFirstComponent
MyFirstComponent,
Page1Component,
Page2Component,
Page3Component
],
imports: [
BrowserModule,
Expand Down
1 change: 1 addition & 0 deletions frontend/angular/src/app/pages/page1/page1.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>page1 works!</p>
Empty file.
23 changes: 23 additions & 0 deletions frontend/angular/src/app/pages/page1/page1.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { Page1Component } from './page1.component';

describe('Page1Component', () => {
let component: Page1Component;
let fixture: ComponentFixture<Page1Component>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ Page1Component ]
})
.compileComponents();

fixture = TestBed.createComponent(Page1Component);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions frontend/angular/src/app/pages/page1/page1.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-page1',
templateUrl: './page1.component.html',
styleUrls: ['./page1.component.scss']
})
export class Page1Component {

}
1 change: 1 addition & 0 deletions frontend/angular/src/app/pages/page2/page2.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>page2 works!</p>
Empty file.
23 changes: 23 additions & 0 deletions frontend/angular/src/app/pages/page2/page2.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { Page2Component } from './page2.component';

describe('Page2Component', () => {
let component: Page2Component;
let fixture: ComponentFixture<Page2Component>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ Page2Component ]
})
.compileComponents();

fixture = TestBed.createComponent(Page2Component);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions frontend/angular/src/app/pages/page2/page2.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-page2',
templateUrl: './page2.component.html',
styleUrls: ['./page2.component.scss']
})
export class Page2Component {

}
1 change: 1 addition & 0 deletions frontend/angular/src/app/pages/page3/page3.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>page3 works!</p>
Empty file.
23 changes: 23 additions & 0 deletions frontend/angular/src/app/pages/page3/page3.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { Page3Component } from './page3.component';

describe('Page3Component', () => {
let component: Page3Component;
let fixture: ComponentFixture<Page3Component>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ Page3Component ]
})
.compileComponents();

fixture = TestBed.createComponent(Page3Component);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
10 changes: 10 additions & 0 deletions frontend/angular/src/app/pages/page3/page3.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-page3',
templateUrl: './page3.component.html',
styleUrls: ['./page3.component.scss']
})
export class Page3Component {

}

0 comments on commit 2dd664a

Please sign in to comment.