Final AngularJS
Final AngularJS
Lab Manual
Academic Year
2023-24
TABLE OF CONTENTS
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Department Vision
The Department of Information Science and Engineering strives to be a center of learning in the field of
Information Technology to produce globally competent engineers catering to the needs of the industry and
society.
Department Mission
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
1. Graduates will succeed in the field of Information Science and Engineering, professional career and higher studies.
2. Graduates will analyze the requirements of the software industries and provide novel engineering designs and efficient
solutions with legal and ethical responsibility.
3. Graduates will adapt to emerging technologies, work in multidisciplinary teams with effective communication skills
and leadership qualities.
PROGRAM OUTCOMES
1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an
engineering specialization to the solution of complex engineering problems.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems reaching
substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences.
3. Design/development of solutions: Design solutions for complex engineering problems and design system components
or processes that meet the specified needs with appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations.
4. Conduct investigations of complex problems: Use research-based knowledge and research methods including design
of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools
including prediction and modeling to complex engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal, health, safety,
legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice.
7. Environment and Sustainability: Understand the impact of the professional engineering solutions in societal and
environmental contexts, and demonstrate the knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering
practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in
multidisciplinary settings.
10. Communication: Communicate effectively on complex engineering activities with the engineering community and
with society at large, such as, being able to comprehend and write effective reports and design documentation, make
effective presentations, and give and receive clear instructions.
11. Project management and finance: Demonstrate knowledge and understanding of the engineering and management
principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in
multidisciplinary environments.
12. Life-long learning: Recognize the need for, and have the preparation and ability to engage in independent and life-
long learning in the broadest context of technological change.
1. An ability to understand, analyse and impart the basic knowledge of Information Science and Engineering.
2. An ability to apply the programming, designing, and problem-solving techniques in building/simulating the
applications, solving the problems and guiding the innovative career paths to become an IT Engineer.
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
COURSE PRE-REQUISITES:
COURSE OBJECTIVES:
2 To understand the Angular JS Modules, Forms, inputs, expression, data bindings and Filters
To gain experience of modern tool usage (VS Code, Atom or any other] in developing Web
3
applications
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
PROGRAMME ISE
SEMESTER IV
CREDITS 01
L-T-P-S 0-0-2-0
CONTACT HOURS/WEEK 2
COURSE CATEGORY
Medium
(ASSESSMENT)
COURSE CONTENT:
Experiments CONTENTS HOURS
Develop Angular JS program that allows user to input their first name and
1 last name and display their full name. Note: The default values for first 2
name and last name may be included in the program.
Develop an Angular JS application that displays a list of shopping items. 2
2 Allow users to add and remove items from the list using directives and
controllers. Note: The default values of items may be included in the
program.
Develop a simple Angular JS calculator application that can perform basic 2
3 mathematical operations (addition, subtraction, multiplication, division)
based on user input.
Write an Angular JS application that can calculate factorial and compute 2
4
square based on given user input.
Develop AngularJS application that displays a details of students and their 2
5 CGPA. Allow users to read the number of students and display the count.
Note: Student details may be included in the program.
Develop an AngularJS program to create a simple to-do list application. 2
6 Allow users to add, edit, and delete tasks. Note: The default values for tasks
may be included in the program.
Write an AngularJS program to create a simple CRUD application (Create, 2
7
Read, Update, and Delete) for managing users.
Develop AngularJS program to create a login form, with validation for the 2
8
username and password fields.
Create an AngularJS application that displays a list of employees and their 2
9 salaries. Allow users to search for employees by name and salary. Note:
Employee details may be included in the program.
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
COURSE PRE-REQUISITES:
COURSE COURSE
DESCRIPTION SEM
NAME CODE
Web
Programming Fundamentals of HTML, Javascript 21CSL481 IV
Laboratory
COURSE DESCRIPTION:
The course covers basics of Angular JS framework, Angular JS Modules, Forms, inputs and
expression. The course provides fundamentals of data bindings ,Filters and enables developing single
page interactive Web applications.
COURSE OBJECTIVES:
This course will enable the students to:
2 To understand the Angular JS Modules, Forms, inputs, expression, data bindings and Filters
To gain experience of modern tool usage (VS Code, Atom or any other] in developing Web
3
applications
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
CO:3 Make use of form validations and controls for interactive applications
CO:4 Apply the concepts of Expressions, data bindings and filters in developing
Angular JS programs
CO:5 Make use of modern tools to develop Web applications
1 2 3 4 5 6 7 8 9 10 11 12 1 2
CO:1 3 2 2 2 3 2
CO:2 3 2 2 2 3 2
CO:3 3 2 2 2 3 2
CO:4 3 2 2 2 3 2
CO:5 3 2 2 2 3 2
Course Articulation 3 2 2 2 3 2
level
Course Outcome Addresses Program Outcomes: 1–slight, 2– Moderate, 3 – Substantial
Rubrics for course articulation level: 66% and above – Articulation Level 3
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
5 The course outcome 5 has been mapped substantially to PO1, as Students apply the
knowledge of engineering fundamentals and principles of Web programming.
Mapped moderately to PO2, as students identify and review complex engineering
problems using principles of Engineering Sciences. Mapped moderately to PO3, as
students design web applications that meet the specified needs with appropriate
consideration for the public, business. The course outcome is mapped substantially
to PO5, as Students select the modern tools like Visual Studio Code, Atom for
developing better web applications. Mapped substantially to PO12, as students
engage in lifelong learning in the context of building web applications using
upgraded web technology. Mapped moderately to PSO 2 as students apply the
programming, designing in building the applications and guiding them innovative
career path.
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
ANGULAR JS
(Practical based)
Course Code: 21CSL581 CIE Marks 50
Teaching Hours/Week 0:0:2:0 SEE Marks 50
Total No. of Hours 12T + 12P Total Marks 100
Credits 01 Exam Hours 02
Sl. Contact Page
No Experiment hours No
Develop Angular JS program that allows user to input their first name
1 and last name and display their full name. Note: The default values for 02 1
first name and last name may be included in the program.
Develop an Angular JS application that displays a list of shopping
items. Allow users to add and remove items from the list using
2 02 3
directives and controllers. Note: The default values of items may be
included in the program.
Develop a simple Angular JS calculator application that can perform
3 basic mathematical operations (addition, subtraction, multiplication, 02 5
division) based on user input.
Write an Angular JS application that can calculate factorial and
4 02 7
compute square based on given user input.
Develop AngularJS application that displays a details of students and
5 their CGPA. Allow users to read the number of students and display 02 9
the count. Note: Student details may be included in the program.
Develop an AngularJS program to create a simple to-do list
6 application. Allow users to add, edit, and delete tasks. Note: The 02 11
default values for tasks may be included in the program.
Write an AngularJS program to create a simple CRUD application
7 02 15
(Create, Read, Update, and Delete) for managing users.
Develop AngularJS program to create a login form, with validation for
8 02 18
the username and password fields.
Create an AngularJS application that displays a list of employees and
9 their salaries. Allow users to search for employees by name and salary. 02 20
Note: Employee details may be included in the program.
Create AngularJS application that allows users to maintain a collection
of items. The application should display the current total number of
10 items, and this count should automatically update as items are added 02 22
or removed. Users should be able to add items to the collection and
remove them as needed.
11 Note: The default values for items may be included in the program. 02 25
Create AngularJS application to convert student details to Uppercase
12 02 27
using angular filters.
Assessment Details (both CIE and SEE)
The weightage of Continuous Internal Evaluation (CIE) is 50% and for Semester End Exam (SEE) is 50%. The
minimum passing mark for the CIE is 40% of the maximum marks (20 marks). A student shall be deemed to have
satisfied the academic requirements and earned the credits allotted to each course. The student has to secure not
less than 35% (18 Marks out of 50) in the semester-end examination (SEE).
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
NOTE: List of experiments to be prepared by the faculty based on the syllabus mentioned above
The split-up of CIE marks for record/ journal and test are in the ratio 60:40.
Each experiment to be evaluated for conduction with observation sheet and record write-up. Rubrics for the
evaluation of the journal/write-up for hardware/software experiments designed by the faculty who is handling
the laboratory session and is made known to students at the beginning of the practical session.
Record should contain all the specified experiments in the syllabus and each experiment write-up will be
evaluated for 10 marks.
Total marks scored by the students are scaled downed to 30 marks (60% of maximum marks).
Weightage to be given for neatness and submission of record/write-up on time.
Department shall conduct 02 tests for 100 marks, the first test shall be conducted after the 8th week of the
semester and the second test shall be conducted after the 14 th week of the semester.
In each test, test write-up, conduction of experiment, acceptable result, and procedural knowledge will carry
a weightage of 60% and the rest 40% for viva-voce.
The suitable rubrics can be designed to evaluate each student’s performance and learning ability. Rubrics
suggested in Annexure-II of Regulation book
The average of 02 tests is scaled down to 20 marks (40% of the maximum marks).
The Sum of scaled-down marks scored in the report write-up/journal and average marks of two tests is the total CIE
marks scored by the student.
Semester End Evaluation (SEE):
Dept. of ISE
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Program 1: Develop Angular JS program that allows user to input their first name and
last name and display their full name. Note: The default values for first name and last
name may be included in the program.
Description:
Users can input their first and last names into an AngularJS program, which then displays their
entire name. 'Rajender' and 'Tilak' are the default values assigned to the first and last names.
These values are modifiable in the controller (myCtrl) as needed.
Program1.html
<!DOCTYPE html>
<html>
<head>
<title>Full Name Program</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>Full Name Program</h1>
<input type="text" ng-model="firstName" placeholder="Enter First Name">
<input type="text" ng-model="lastName" placeholder="Enter Last Name">
<br>
Full Name: {{firstName + " " + lastName}}
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.firstName = "Rajender";
$scope.lastName = "Tilak";
});
</script>
</body>
</html>
Dept. of ISE 1
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
OUTPUT:
----------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Dept. of ISE 2
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Description:
AngularJS application that shows a shopping list and lets users edit the list by adding and
removing items with controllers and directives. The shopping list is managed by this AngularJS
application using a controller called myCtrl. The item list is displayed using ng-repeat, and
there is an input field for adding new items. When an item is clicked on the "Remove Item"
button next to each one, it is removed from the list. Clicking the "Add Item" button adds the
entered item to the list. The items in the default list are "Eggs," "Bread," and "Milk.".
Program2.html
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Shopping List App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>Shopping List App</h1>
<ul>
<li ng-repeat="item in items">{{item}}</li>
</ul>
<input type="text" ng-model="newItem" placeholder="Enter New Item">
<button ng-click="addItem()">Add Item</button>
<button ng-click="removeItem(index)">Remove Item</button>
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.items = ["Milk", "Bread", "Eggs"];
$scope.addItem = function() {
$scope.items.push($scope.newItem);
$scope.newItem = "";
};
$scope.removeItem = function(index) {
$scope.items.splice(index, 1);
};
});
</script>
</body>
</html>
Dept. of ISE 3
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
OUTPUT:
----------------------------------------------------------------------------------------------------------------
After adding items:
----------------------------------------------------------------------------------------------------------------
After removing items:
----------------------------------------------------------------------------------------------------------------
Dept. of ISE 4
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Program3.html
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Calculator App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>Calculator App</h1>
<input type="number" ng-model="num1" placeholder="Enter First Number">
<input type="number" ng-model="num2" placeholder="Enter Second Number">
<select ng-model="operator">
<option value="+">+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
</select>
<button ng-click="calculate()">Calculate</button>
<p>Result: {{result}}</p>
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.num1 = 0;
$scope.num2 = 0;
$scope.operator = "+";
$scope.result = 0;
$scope.calculate = function() {
switch ($scope.operator) {
case "+":
$scope.result = parseFloat($scope.num1) + parseFloat($scope.num2);
break;
Dept. of ISE 5
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
case "-":
$scope.result = $scope.num1 - $scope.num2;
break;
case "*":
$scope.result = $scope.num1 * $scope.num2;
break;
case "/":
$scope.result = $scope.num1 / $scope.num2;
break;
}
};
});
</script>
</body>
</html>
OUTPUT:
Dept. of ISE 6
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
P4.html
<!DOCTYPE html>
<html>
<head>
<title>AngularJS Factorial and Square Calculator App</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js">
</script>
</head>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<h1>Factorial and Square Calculator App</h1>
<input type="number" ng-model="number" placeholder="Enter a Number">
<button ng-click="calculateFactorial()">Calculate Factorial</button>
<button ng-click="calculateSquare()">Calculate Square</button>
<p>Factorial: {{factorial}}</p>
<p>Square: {{square}}</p>
</div>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.number = 0;
$scope.factorial = 0;
$scope.square = 0;
$scope.calculateFactorial = function() {
var factorial = 1;
for (var i = $scope.number; i > 1; i--) {
factorial *= i;
}
$scope.factorial = factorial;
};
$scope.calculateSquare = function() {
$scope.square = $scope.number * $scope.number;
};
});
</script>
Dept. of ISE 7
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
</body>
</html>
OUTPUT:
----------------------------------------------------------------------------------------------------------------
Dept. of ISE 8
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
P5.html
<!DOCTYPE html>
<html >
<head>
<title>Student Details with CGPA</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js">
</script>
</head>
<body ng-app="myApp">
<div ng-controller="myController">
<h2>Student Details</h2>
<p>Total number of students: {{ students.length }}</p>
<table border="1">
<tr>
<th>Name</th>
<th>CGPA</th>
</tr>
<tr ng-repeat="student in students">
<td>{{ student.name }}</td>
<td>{{ student.cgpa }}</td>
</tr>
</table>
</div>
<script src="Program5.js"> </script>
</body>
</html>
Dept. of ISE 9
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Program5.js
var app = angular.module('myApp', []);
app.controller('myController', function ($scope) {
// Default student details
$scope.students = [
{ name: 'Akshaya', cgpa: 8.8 },
{ name: 'Krishna Patel', cgpa: 7.2 },
{ name: 'Johnson', cgpa: 6.5 },
{ name: 'Safwan', cgpa: 7.5},
{ name: 'Zeenath', cgpa: 8.5}
];
});
OUTPUT:
Dept. of ISE 10
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
P6.html
<!DOCTYPE html>
<html>
<head>
<title>To-Do List Application</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js">
</script>
</head>
<body ng-app="myApp">
<div ng-controller="myController">
<h2>To-Do List</h2>
<ul>
<li ng-repeat="task in tasks">
{{ task.name }}
<button ng-click="editTask(task)">Edit Task</button>
<button ng-click="deleteTask(task)">DeleteTask</button>
</li>
</ul>
<div>
<label>New Task: </label>
<input type="text" ng-model="newTaskName">
<button ng-click="addTask()">Add Task</button>
</div>
<div ng-show="editingTask">
<label>Edit Task: </label>
<input type="text" ng-model="editedTaskName">
<button ng-click="saveTask()">Save</button>
<button ng-click="cancelEdit()">Cancel</button>
Dept. of ISE 11
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
</div>
</div>
<script src="Program6.js"> </script>
</body>
</html>
Program6.js
// Default tasks
$scope.tasks = [
{ name: 'Attend Class'},
{ name: 'Complete Assignment'},
{ name: 'Study for CIE'}
];
$scope.addTask = function () {
if ($scope.newTaskName) {
$scope.tasks.push({ name: $scope.newTaskName });
$scope.newTaskName = ' ';
}
};
$scope.saveTask = function () {
if ($scope.editingTask) {
$scope.editingTask.name = $scope.editedTaskName;
$scope.cancelEdit();
}
};
$scope.cancelEdit = function () {
$scope.editingTask = null;
$scope.editedTaskName = '';
Dept. of ISE 12
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
};
OUTPUT:
--------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------
Dept. of ISE 13
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
----------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Dept. of ISE 14
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
P7.html
<!DOCTYPE html>
<html ng-app="userApp">
<head>
<title>AngularJS CRUD Application for Users</title>
</head>
<body ng-controller="UserController">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/angularjs/1.8.2/a
ngular.min.js"> </script>
<h1>User Management</h1>
<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="user in users">
<td>{{ user.name }}</td>
<td>{{ user.email }}</td>
<td>
<button ng-click="editUser(user)">Edit</button>
<button ng-click="deleteUser(user)">Delete</button>
</td>
</tr>
</tbody>
</table>
<hr>
<h2>Create User</h2>
Dept. of ISE 15
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
<hr>
<h2>Edit User</h2>
<script src="Program7.js"></script>
</body>
</html>
Program7.js
Dept. of ISE 16
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
OUTPUT:
----------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------
Dept. of ISE 17
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Pgm8.html
<!DOCTYPE html>
<html>
<head>
<title>Login Form with Validation</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js">
</script>
</head>
<body ng-app="myApp">
<div ng-controller="LoginController">
<h2>Login Form</h2>
<label>Password:</label>
<input type="password" ng-model="user.password" name="password" ng-
pattern="/^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$/" required>
Dept. of ISE 18
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Program8.js
OUTPUT:
--------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------
Dept. of ISE 19
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Description:
The AngularJS application that displays a list of employees and their salaries. Employees are
displayed in an unordered list (<ul>). Users can search for employees by name and salary using
the ng-model directive. The filter pipe is used to filter employees based on the search criteria
(name and salary). Employee salaries are formatted using the number filter to display two
decimal places.
Pgm9.html
<!doctype html>
<html ng-app>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script>
</head>
<body>
<div>
<div ng-app="myApp">
<div ng-controller="EmployeeController">
<h1>Employee List</h1>
<input type="text" ng-model="searchName" placeholder="Search by name">
<input type="number" ng-model="searchSalary" placeholder="Search by salary">
<button ng-click="searchEmployees()">Search</button>
<ul>
<li ng-repeat="employee in employees">{{employee.name}} - {{employee.salary}}</li>
</ul>
</div>
</div>
<script src= “ Program9.js”></script>
</body>
</html>
Program9.js
myApp.controller('EmployeeController', function($scope) {
$scope.employees = [
{ name: 'John Doe', salary: 50000 },
{ name: 'Jane Doe', salary: 60000 },
{ name: 'Peter Parker', salary: 70000 },
{ name: 'Mary Jane Watson', salary: 80000 }
];
$scope.searchEmployees = function() {
$scope.employees = $scope.employees.filter(function(employee) {
Dept. of ISE 20
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
OUTPUT:
-------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------
-
----------------------------------------------------------------------------------------------------------------------------------
Dept. of ISE 21
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Description:
The AngularJS application that allows users to maintain a collection of items. The application
displays the current total number of items, and this count updates automatically as items are
added or removed. The total number of items is displayed using {{ items.length }}. Items are
displayed in an unordered list (<ul>). Users can add a new item by entering the item name and clicking
the "Add Item" button. Each item has a "Remove" button that allows users to remove the item from
the collection.
P10.html
<!DOCTYPE html>
<html>
<head>
<title>Item Collection Management</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js">
</script>
</head>
<body ng-app="myApp">
<div ng-controller="ItemController">
<h2>Item Collection</h2>
<ul>
<li ng-repeat="item in items">
{{ item.name }}
<button ng-click="removeItem(item)">Remove</button>
</li>
</ul>
<div>
<label>New Item: </label>
<input type="text" ng-model="newItemName">
<button ng-click="addItem()">Add Item</button>
</div>
</div>
<script src= “Program10.js”></script>
</body>
</html>
Dept. of ISE 22
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Program10.js
var app = angular.module('myApp', []);
$scope.newItemName = '';
$scope.addItem = function () {
if ($scope.newItemName) {
$scope.items.push({ name: $scope.newItemName });
$scope.newItemName = '';
}
};
OUTPUT:
-------------------------------------------------------------------------------------------------------------------------------
Dept. of ISE 23
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
--------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------
Dept. of ISE 24
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
P11.html
<!DOCTYPE html>
<html>
<head>
<title>Student Details</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-app="myApp">
<h1>Student Details</h1>
<table>
<thead>
<tr>
<th>Name</th>
<th>CGPA</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="student in students">
<td>{{student.name | uppercase}}</td>
<td>{{student.cgpa}}</td>
</tr>
</tbody>
</table>
<script src= “P11.js”></script>
</body>
</html>
Dept. of ISE 25
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
P11.js
angular.module('myApp', []).controller('appCtrl', function($scope) {
$scope.students = [
{ name: "John Doe", cgpa: 3.8 },
{ name: "Jane Doe", cgpa: 3.6 },
{ name: "Peter Parker", cgpa: 3.9 },
{ name: "Mary Jane Watson", cgpa: 3.7 }
];
});
OUTPUT:
Dept. of ISE 26
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Program 12: Create an AngularJS application that displays the date by using date
filter parameters
Description:
AngularJS date filter is used to convert a date into a specified format. When the date format is
not specified, the default date format is ‘MMM d, yyyy’.
Syntax:
{{ date | date : format : timezone }}
Parameter Values: The date filter contains format and timezone parameters which is optional.
In this program the user can select a date format from a dropdown list. The ng-change directive
is used to trigger the updateDate function whenever the selected format changes. The
updateDate function uses the AngularJS $filter service to format the current date based on the
selected format. Formatted date is then displayed in the HTML.
P12.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AngularJS Date Display</title>
<script
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-app="myApp">
<div ng-controller="myController">
<h2>Date Display</h2>
<label>Date Format:
<select ng-model="selectedFormat" ng-change="updateDate()">
<option value="fullDate">Full Date</option>
<option value="shortDate">Short Date</option>
<option value="mediumTime">Medium Time</option>
<option value="shortTime">short Time</option>
<option value="yyyy-MM-dd HH:mm:ss">Custom Format (yyyy-MM-dd
HH:mm:ss)</option>
</select>
</label>
Dept. of ISE 27
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
</body>
</html>
P12.js
var app = angular.module('myApp', []);
app.controller('myController', function ($scope, $filter) {
$scope.selectedFormat = 'fullDate'; // Default date format
$scope.updateDate = function () {
var currentDate = new Date();
$scope.formattedDate = $filter('date')(currentDate, $scope.selectedFormat);
};
// Initial date update
$scope.updateDate();
});
OUTPUT:
Dept. of ISE 28
Canara Engineering College, Banjanapadavu AngulaJS Lab Manual(21CSL581)
Dept. of ISE 29