Created
April 23, 2025 15:48
-
-
Save kavicastelo/140d73279ca2ef24d1982b578d04ab43 to your computer and use it in GitHub Desktop.
Angular Learning Module 3 (Interns) – Reusable Layout + Navigation + Feature Modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Routes } from '@angular/router'; | |
| import { LayoutComponent } from './layout/layout.component'; | |
| import { DashboardComponent } from './dashboard/dashboard.component'; | |
| import { ProfileComponent } from './profile/profile.component'; | |
| import { MessagesComponent } from './messages/messages.component'; | |
| export const routes: Routes = [ | |
| { | |
| path: '', | |
| component: LayoutComponent, | |
| children: [ | |
| { path: 'dashboard', component: DashboardComponent }, | |
| { path: 'profile', component: ProfileComponent }, | |
| { path: 'messages', component: MessagesComponent }, | |
| { path: '', redirectTo: 'dashboard', pathMatch: 'full' } | |
| ] | |
| }, | |
| { path: '**', redirectTo: '' } | |
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| import { CommonModule } from '@angular/common'; | |
| @Component({ | |
| selector: 'app-dashboard', | |
| standalone: true, | |
| imports: [CommonModule], | |
| template: `<h2>Welcome to the Dashboard</h2>` | |
| }) | |
| export class DashboardComponent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| header { | |
| background: #222; | |
| color: #fff; | |
| padding: 1rem; | |
| text-align: center; | |
| } | |
| .container { | |
| display: flex; | |
| } | |
| nav { | |
| width: 200px; | |
| background: #f5f5f5; | |
| padding: 1rem; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 10px; | |
| } | |
| nav a { | |
| text-decoration: none; | |
| color: #333; | |
| } | |
| nav a.active { | |
| font-weight: bold; | |
| color: #007bff; | |
| } | |
| main { | |
| flex: 1; | |
| padding: 1rem; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <header> | |
| <h1>My Intern Dashboard</h1> | |
| </header> | |
| <div class="container"> | |
| <nav> | |
| <a routerLink="/dashboard" routerLinkActive="active">Dashboard</a> | |
| <a routerLink="/profile" routerLinkActive="active">Profile</a> | |
| <a routerLink="/messages" routerLinkActive="active">Messages</a> | |
| </nav> | |
| <main> | |
| <router-outlet></router-outlet> | |
| </main> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| import { RouterModule } from '@angular/router'; | |
| import { CommonModule } from '@angular/common'; | |
| @Component({ | |
| selector: 'app-layout', | |
| standalone: true, | |
| imports: [CommonModule, RouterModule], | |
| templateUrl: './layout.component.html', | |
| styleUrls: ['./layout.component.css'], | |
| }) | |
| export class LayoutComponent {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| import { CommonModule } from '@angular/common'; | |
| @Component({ | |
| selector: 'app-messages', | |
| standalone: true, | |
| imports: [CommonModule], | |
| template: ` | |
| <h2>Messages</h2> | |
| <ul> | |
| <li *ngFor="let msg of messages">{{ msg }}</li> | |
| </ul> | |
| ` | |
| }) | |
| export class MessagesComponent { | |
| messages = ['Hello!', 'Remember to push your code.', 'Great job so far!']; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component } from '@angular/core'; | |
| import { CommonModule } from '@angular/common'; | |
| @Component({ | |
| selector: 'app-profile', | |
| standalone: true, | |
| imports: [CommonModule], | |
| template: ` | |
| <h2>User Profile</h2> | |
| <p>Name: Intern</p> | |
| <p>Role: Frontend Learner</p> | |
| ` | |
| }) | |
| export class ProfileComponent {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment