Since it's not possible to create a fully functional webpage here, I will provide you with the basic concepts, structure, and code snippets on how to create the webpage you described using Angular. You can then modify and adapt the code accordingly as per your individual preferences.
Step 1: Creating a new Angular Project
First, create a new Angular project using the Angular CLI:
ng new my-webpage
Step 2: Creating Components
In your new Angular project folder, create components for each of the desired pages:
ng generate component home
ng generate component planets
ng generate component about-us
ng generate component contact-us
Step 3: Creating Angular Routing
Update the app.module.ts file to import the RouterModule and define the routes:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { PlanetsComponent } from './planets/planets.component';
import { AboutUsComponent } from './about-us/about-us.component';
import { ContactUsComponent } from './contact-us/contact-us.component';
const appRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'planets', component: PlanetsComponent },
{ path: 'about-us', component: AboutUsComponent },
{ path: 'contact-us', component: ContactUsComponent }
];
@NgModule({
declarations: [
AppComponent,
HomeComponent,
PlanetsComponent,
AboutUsComponent,
ContactUsComponent
],
imports: [
BrowserModule,
RouterModule.forRoot(appRoutes)
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Step 4: Creating Navigation Panel
In the app.component.html file, create the navigation panel using the routerLink directive:
<nav>
<ul>
<li><a routerLink="/">Home</a></li>
<li><a routerLink="/planets">Planets</a></li>
<li><a routerLink="/about-us">About Us</a></li>
<li><a routerLink="/contact-us">Contact Us</a></li>
</ul>
</nav>
<router-outlet></router-outlet>
Step 5: Implementing Components
Now, you can proceed to implement each of the components as desired. Here are some basic examples:
- Home Component (home.component.html):
<h1>Welcome to My Webpage</h1>
<p>This is the home page of my webpage.</p>
- Planets Component (planets.component.ts):
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-planets',
templateUrl: './planets.component.html',
styleUrls: ['./planets.component.css']
})
export class PlanetsComponent implements OnInit {
planets = [
{ name: "Earth", discoveryYear: "N/A", description: "Our Home Planet" },
{ name: "Mars", discoveryYear: "N/A", description: "The Red Planet" },
];
constructor() { }
ngOnInit(): void {
}
}
(planets.component.html):
<div *ngFor="let planet of planets">
<h2>{{planet.name}}</h2>
<p>Discovery Year: {{planet.discoveryYear}}</p>
<p>{{planet.description}}</p>
</div>
- About us (about-us.component.html):
<h2>About Us</h2>
<img src="your-image-url" alt="Your Name">
<h3>Your Name</h3>
<p>Year: Your Year</p>
<p>Department: Your Department</p>
<p>A small description about you...</p>
- Contact Us (contact-us.component.html):
<form (ngSubmit)="onSubmit()" #contactForm="ngForm">
<label>
Name:
<input type="text" [(ngModel)]="name" name="name" required>
</label>
<label>
Sap Id:
<input type="text" [(ngModel)]="sapId" name="sapId" required>
</label>
<label>
Did you like the site?
<input type="checkbox" [(ngModel)]="likeSite" name="likeSite">
</label>
<label>
Feedback:
<textarea [(ngModel)]="feedback" name="feedback"></textarea>
</label>
<button type="submit">Submit</button>
</form>
(contact-us.component.ts):
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-contact-us',
templateUrl: './contact-us.component.html',
styleUrls: ['./contact-us.component.css']
})
export class ContactUsComponent implements OnInit {
name = '';
sapId = '';
likeSite = false;
feedback = '';
constructor() { }
ngOnInit(): void {
}
onSubmit() {
console.log({
name: this.name,
sapId: this.sapId,
likeSite: this.likeSite,
feedback: this.feedback
});
}
}
Now you should have a basic working webpage with routing according to the specified requirements. Remember to modify the content accordingly and style the components using CSS.