Updating using AngularJS
Shopping.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta>
<title>Shopping</title>
</head>
<body>
<h1>Two Way Data Binding Example</h1><br>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular-resource.min.js">
</script>
<script src="Shopping.js"></script>
<div ng-app>
<div ng-controller="ShoppingCartCtrl">
<br />
<table border="1">
<thead>
<tr>
<td>Name</td>
<td>Price</td>
<td>Quantity</td>
<td>Remove Item</td>
</tr>
</thead>
<tbody ng-repeat="item in items">
<tr>
<td>{{item.Name}}</td>
<td>{{item.Price}}</td>
<td>{{item.Quantity}}</td>
<td><input type="button" value="Remove" ng-click="removeItem($index)" /></td>
</tr>
</tbody>
</table>
<br />
<div>Total Price: {{totalPrice()}}</div>
<br />
<table>
<tr>
<td>Name: </td>
<td><input type="text" ng-model="item.Name" /></td>
</tr>
<tr>
<td>Price: </td>
<td><input type="text" ng-model="item.Price" /></td>
</tr>
<tr>
<td>Quantity: </td>
<td><input type="text" ng-model="item.Quantity" /></td>
</tr>
<tr>
<td colspan="2"><input type="Button" value="Add" ng-click="addItem(item)" /> </td>
</tr>
</table>
</div>
</div>
</body>
</html>
Shopping.js
function ShoppingCartCtrl($scope) {
$scope.items = [
{Name: "Soap", Price: "25", Quantity: "10"},
{Name: "Shaving cream", Price: "50", Quantity: "15"},
{Name: "Shampoo", Price: "100", Quantity: "5"}
];
$scope.addItem = function(item) {
$scope.items.push(item);
$scope.item = {};
}
$scope.totalPrice = function(){
var total = 0;
for(count=0;count<$scope.items.length;count++){
total += $scope.items[count].Price*$scope.items[count].Quantity;
}
return total;
}
$scope.removeItem = function(index){
$scope.items.splice(index,1);
}
}
This is the demo example code for adding data and deleting data using angularJS. I want to add one more button for updating items in the table for Updating Items in Shopping.html. On clicking updating button for each row ( as like Remove button in each row) I want the items in table (for that row for which we clicked Update button) comes in edit mode and Update button changes to Save button for that particular row. I want to do all this functionality using AngularJS and updation also with Two way binding (As in angularJS). Please help me to do the given functinality using full feautres of AngularJS. I searched many examples but unable to find so.
Thanks and Regards,
Gurpreet Singh
View Answers
Related Tutorials/Questions & Answers:
Updating using AngularJSUpdating using AngularJS Shopping.html
<!DOCTYPE HTML PUBLIC...);
}
}
This is the demo example code for adding data and deleting data
using angularJS. I want to add... row. I want to do all this functionality
using AngularJS and updation also
Updating Ms Access Database using jsp - JSP-ServletUpdating Ms Access Database
using jsp Hi
I am new to jsp and I am trying to update a record in an access database. I only want to update part of the record because the other columns already have data. When I use Update
Advertisements
What are prerequisite for learning angularjs?What are prerequisite for learning
angularjs? Hi,
I have to learn
angularjs for next project. What are prerequisite for learning
angularjs?
Thanks
Hi,
What are the prerequisites for learning
angularjs?
Reply fast
Download and Install AngularJS CDN network, if you
prefer to use the
AngularJS then you can include it
using...
In this example we have defined a controller in
AngularJS using following...Download and Install
AngularJS in a project
As mentioned earlier Download
AngularJS Hello World Program AngularJS is to develop the program
using the simple
text editor or notepad...
AngularJS Hello World Program - Create and run your first
AngularJS example
that prints Hello message
The
AngularJS is very popular front end development
writing angularjs hello world programwriting
angularjs hello world program Hi,
I just started to learn the
AngularJS framework. I want to learn it fast and looking for easy to learn... World program in
AngularJS.
Searching for simple example for writing
angularjs AngularJS TutorialsAngularJS frontend framework Tutorials
In this section we are going to provide you easy to learn and try tutorials
of popular
AngularJS framework which...
AngularJS in just 2-4
days. Follow our
AngularJS tutorials and learn
Updating multiple value depending on checkboxesUpdating multiple value depending on checkboxes Hi .. I want to Update the multiple values of database
using checkboxes and want to set the session for selected checkboxes..? please answer if any one knows as soon as possible
updating a table in a database - SQLupdating a table in a database give me complete source code in java to execute the sqlquery such that
(update table_name set phone no=? where cous_id=?). or in simple way give me source code to update my table in MsAccess
Updating user profileUpdating user profile how should i provide user to update his profile with edit option including entered data by user should be shown in jsp page fileds
The given code retrieve data from database and display
Update Records using Prepared Statement for
updating the records. In this JDBC tutorial we are going to learn
about the process of
updating the records by
using the PreparedStatement.
Here arise... Update Records
using Prepared Statement
Problem in updating query in Hibernate - HibernateProblem in
updating query in Hibernate Hi,
I have used a query to update the existing columns of one table. The query updates the records in the main table but it does not update the tables that are mapped from the main table
Lock while inserting/updating database in multithreaded.Lock while inserting/
updating database in multithreaded. Hi,
I am... inserting/
updating to database. I dont know what is the issue but it was never... am
using ojdbc5.jar for jdbc connection.
Please help me out, its killing me
updating an access database with visual basic 2010updating an access database with visual basic 2010 I am building a program in visual basic 2010 that connects to an access database. I was wondering if you could help me figure out the code for the save button. When
updating column automatically based on system dateupdating column automatically based on system date hi,
can any one give solution for my question
i have a table called leave balanced(leave-id,leave balance,etc are column),in leave balance column each employee has some leave
Ios Swift developer for updating current appIos Swift developer for
updating current app Hi,
I have previously developed iOS application in Swift programming language. This application is developed in Swift and some of the Objective C libraries.
Developer must know
what is wrong with my JSP codes for updating a form?what is wrong with my JSP codes for
updating a form? Hi experts,
I have tried to emulate a code from a textbook but it doesn't work in my program. Hope someone can advise me where I had gone wrong.
Tks.
I've set up my