Practical 4 5 6
Practical 4 5 6
Practical 4: Create a HTML form that will accept Enrollment No., Name, Semester, Branch, Mobile Number, Email,
Address etc. from the student and display them on the page using Angular JS Directives and Expressions.
Solution:
Practical 4.html
<!DOCTYPE html>
<html>
<script src="angular-1.8.2/angular.min.js"></script>
<body ng-app="">
<center>
<div>
<h3>... Student Registration Details ...</h3>
<form method="get" action="">
<table border="1" cellpadding="5px">
<tr>
<td>Enrollment No.</td>
<td><input type="text" ng-model="eno"></td>
</tr>
<tr>
<td>Name</td>
<td><input type="text" ng-model="name"></td>
</tr>
<tr>
<td>Semester</td>
<td>
<select ng-model="semester">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</td>
</tr>
<tr>
<td>Branch</td>
<td>
<select ng-model="branch">
<option value="E.C.">E.C.</option>
<option value="Electrical">Electrical</option>
<option value="I.T.">I.T.</option>
</select>
</td>
</tr>
6th Semester IT (SSEC, Bhavnagar) Page No: xx
Advance Web Programming (3161611)
<tr>
<td>Gender</td>
<td>
<input type="radio" name="radgender" ng-model="gender" value="Male">Male
<input type="radio" name="radgender" ng-model="gender" value="Female">Female
</td>
</tr>
<tr>
<td>Mobile</td>
<td><input type="text" ng-model="mobile"></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" ng-model="email"></td>
</tr>
<tr>
<td>Address</td>
<td><textarea ng-model="address"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit">
<input type="reset">
</td>
</tr>
</table>
</form>
<br/><br/>
<h3>... Filled Student Registration Details ...</h3>
<div>
<table border="1" cellpadding="5px">
<tr>
<td>Enrollment No. :</td>
<td width="300px">{{ eno }}</td>
</tr>
<tr>
<td>Name : </td>
<td>{{ name }}</td>
</tr>
<tr>
<td>Semester : </td>
<td>{{ semester }}</td>
</tr>
<tr>
<td>Branch : </td>
<td>{{ branch }}</td>
</tr>
<tr>
<td>Gender : </td>
<td>{{ gender }}</td>
</tr>
Output :
Practical 5: Create a webpage using AngularJS that displays details of students' objects (such as Enrollment No., Name,
Semester, Branch, Mobile Number, Email Address, Address etc.) in a tabular format with appropriate CSS effects.
Solution:
Practical 5.html
<!DOCTYPE html>
<html>
<script src="angular-1.8.2/angular.min.js"></script>
<style>
.striped {
color:black;
background-color:cyan;
}
</style>
<body>
<center>
<div ng-app="myApp" ng-controller="myCtrl">
<table border='1' cellpadding="5px">
<tr>
<th>Enrollment No.</th>
<th width="100px">Name</th>
<th>Branch</th>
<th>Semester</th>
</tr>
<tr ng-repeat="x in students" ng-class-odd="'striped'">
<td>{{x.enrollment}}</td>
<td>{{x.name}}</td>
<td>{{x.branch}}</td>
<td>{{x.semester}}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.students=[
{enrollment:'301',name:'Rajesh',semester:'3',branch:'I.T.'},
{enrollment:'501',name:'Ishwar',semester:'5',branch:'Production'},
{enrollment:'701',name:'Ronit',semester:'7',branch:'Mechanical'}];
});
</script>
</center>
</body>
</html>
Output :
Solution:
Practical 6.html
<html>
<script src="angular-1.8.2/angular.min.js"></script>
<style>
.striped {
color:black;
background-color:cyan;
}
</style>
<body>
<center>
<div ng-app="myApp" ng-controller="myCtrl">
<p>Enter Search String : <input type="text" ng-model="test"></p>
<table border='1' cellpadding="5px">
<tr>
<th ng-click="orderByMe('enrollment')">Enrollment No.</th>
<th width="200px" ng-click="orderByMe('name')">Name</th>
<th ng-click="orderByMe('branch')">Branch</th>
<th ng-click="orderByMe('semester')">Semester</th>
</tr>
<tr ng-repeat="x in students | orderBy:myOrder | filter:test" ng-class-odd="'striped'">
<td>{{x.enrollment}}</td>
<td>{{x.name}}</td>
<td>{{x.branch}}</td>
<td>{{x.semester}}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.students=[
{enrollment:'301',name:'Rajesh',semester:'3',branch:'I.T.'},
{enrollment:'501',name:'Ishwar',semester:'5',branch:'Production'},
{enrollment:'701',name:'Ronit',semester:'7',branch:'Mechanical'}];
$scope.orderByMe = function(x) {
$scope.myOrder = x;
}
});
</script>
</center>
</body>
</html>
6th Semester IT (SSEC, Bhavnagar) Page No: xx
Advance Web Programming (3161611)
Output :