diff --git a/first-app/src/app/app.html b/first-app/src/app/app.html index 8a6876e..0f5e195 100644 --- a/first-app/src/app/app.html +++ b/first-app/src/app/app.html @@ -1,8 +1,7 @@ -
-
- -
+
+
+
- +
\ No newline at end of file diff --git a/first-app/src/app/app.ts b/first-app/src/app/app.ts index 7d0edc2..216e08e 100644 --- a/first-app/src/app/app.ts +++ b/first-app/src/app/app.ts @@ -1,12 +1,13 @@ import {Component} from '@angular/core'; import {Home} from './home/home'; +import {RouterModule} from '@angular/router'; @Component({ - selector: 'app-root', - imports: [Home], - templateUrl: './app.html', - styleUrls: ['./app.css'], + selector: 'app-root', + imports: [Home, RouterModule], + templateUrl: './app.html', + styleUrls: ['./app.css'], }) export class App { - title = 'homes'; + title = 'homes'; } diff --git a/first-app/src/app/details/details.ts b/first-app/src/app/details/details.ts new file mode 100644 index 0000000..e53e236 --- /dev/null +++ b/first-app/src/app/details/details.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'app-details', + imports: [], + template: ` +

+ details works! +

+ `, + styles: `` +}) +export class Details { + +} diff --git a/first-app/src/app/routes.ts b/first-app/src/app/routes.ts new file mode 100644 index 0000000..19dd23d --- /dev/null +++ b/first-app/src/app/routes.ts @@ -0,0 +1,17 @@ +import {Routes} from '@angular/router'; +import {Home} from './home/home'; +import {Details} from './details/details'; + +const routeConfig: Routes = [ + { + path: '', + component: Home, + title: 'Home page', + }, + { + path: 'details/:id', + component: Details, + title: 'Home details', + }, +]; +export default routeConfig; \ No newline at end of file diff --git a/first-app/src/main.ts b/first-app/src/main.ts index 4093863..fd204be 100644 --- a/first-app/src/main.ts +++ b/first-app/src/main.ts @@ -4,7 +4,8 @@ */ import {bootstrapApplication, provideProtractorTestingSupport} from '@angular/platform-browser'; import {App} from './app/app'; - -bootstrapApplication(App, {providers: [provideProtractorTestingSupport()]}).catch((err) => - console.error(err), -); +import {provideRouter} from '@angular/router'; +import routeConfig from './app/routes'; +bootstrapApplication(App, { + providers: [provideProtractorTestingSupport(), provideRouter(routeConfig)], +}).catch((err) => console.error(err)); \ No newline at end of file