IP Record Till EXP 12 127
IP Record Till EXP 12 127
AIM :
Program to develop an attractive web pages using Angular 9.
PROCEDURE:
1. Define a simple controller:
2. After created module and controller, use them in our HTML.
3. Include angular script and app.js that we built.
4. Specify module in ng-app attribute and controller in ng- controller attribute.
5. Start working on adding single page application support.
6. Make a single page application and don’t want any page refreshes, use
Angular’s routing capabilities.
7. Include angular-route script after the main angular script.
8. Specify that the module depends on ngRoute module to be able to use it.
9. The next thing is to distinguish common HTML for every page. This HTML
will be layout of the website.
10. Then specify the place where HTML of each page will be placed in our layout.
There is a ng view directive for that.
11. ng-view is an Angular directive that will include the template of the current
route (for example, /blog or /about) in the main layout file.
12. Configure the routes. Use $routeProvider service from the ngRoute module.
13. For each route, specify templateUrl and controller.
14. If user will try to go to the route that does not exist, handle this by using
otherwise function. In our case, we will redirect user to the “/” route:
15. Build controllers for every route (already specified their names in
routeProvider).
PROGRAM:
//app.component.html
<router-outlet name="header"></router-outlet>
<router-outlet></router-outlet>
//app-routing.module.ts
//navbar.component.html
<nav>
<a routerLink="/register">Register</a> |
<a routerLink="/login">Login</a>
</nav>
<hr>
//navbar.component.css nav{
font-size: 2em;
text-align: center; width: 100%;
} nav a{
text-decoration: none; color:
black; margin: 0.5em; display:
inline-block;
}
//login.component.html
<!DOCTYPE html>
<html>
<head>
<title>Login Form</title>
</head>
<body>
<form action="" method="post"> <table>
<tr>
<td>USER ID:</td>
<td><input type="text" name="user_id"></td>
</tr>
<tr>
<td>PASSWORD:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Login">
</td>
</tr>
</table>
</form>
</body>
</html>
//login.component.css
* { overflow: hidden;
} table {
border-collapse: collapse; width:
55%; margin: 2em auto;
} table, th, td {
border: 1px solid black;
}
th, td {
padding: 10px; text-align: left;
} tr:nth-child(even) {
background-color: #f2f2f2;
} input[type="text"],
input[type="password"] {
width: 96%; padding: 5px;
}
input[type="submit"] {
background-color: black; color:
white; padding: 10px 20px;
border: none; cursor: pointer;
min-width: 200px;
} td[colspan="2"] {
text-align: center;
}
//register.component.html
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<form action="" method="post">
<table>
<tr>
<td>ENTER ROLL NO:</td>
<td><input type="text" name="roll_no"></td>
</tr>
<tr>
<td>ENTER EMAIL ID:</td>
<td><input type="text" name="email_id"></td>
</tr>
<tr>
<td>NAME:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>PASSWORD:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit">
</td>
</tr>
</table>
</form>
</body>
</html>
//register.component.css
*{ overflow: hidden; } table {
border-collapse: collapse; width:
55%; margin: 2em auto; } table, th,
td {
border: 1px solid black; } th, td
{
padding: 10px; text-
align: left; } tr:nth-
child(even) {
background-color: #f2f2f2; }
input[type="text"],
input[type="password"] {
width: 96%; padding: 5px; }
input[type="submit"] {
background-color: black; color:
white; padding: 10px 20px; border:
none; cursor: pointer; min-width:
250px; border-radius: 6px; }
td[colspan="2"] {
text-align: center;
}
OUTPUT:
RESULT:
Thus the given design was successfully developed and output was verified.