Updating using AngularJS

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 AngularJS
Updating 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-Servlet
Updating 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
coding for updating profile
coding for updating profile  coding for updating profile
ModuleNotFoundError: No module named 'django-angularjs'
ModuleNotFoundError: No module named 'django-angularjs'  Hi, My... named 'django-angularjs' How to remove the ModuleNotFoundError: No module named 'django-angularjs' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'robotframework-angularjs'
ModuleNotFoundError: No module named 'robotframework-angularjs'  Hi...: No module named 'robotframework-angularjs' How to remove the ModuleNotFoundError: No module named 'robotframework-angularjs' error? Thanks  
ModuleNotFoundError: No module named 'django-angularjs'
ModuleNotFoundError: No module named 'django-angularjs'  Hi, My... named 'django-angularjs' How to remove the ModuleNotFoundError: No module named 'django-angularjs' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-angularjs'
ModuleNotFoundError: No module named 'django-angularjs'  Hi, My... named 'django-angularjs' How to remove the ModuleNotFoundError: No module named 'django-angularjs' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'pybabel-angularjs'
ModuleNotFoundError: No module named 'pybabel-angularjs'  Hi, My... named 'pybabel-angularjs' How to remove the ModuleNotFoundError: No module named 'pybabel-angularjs' error? Thanks   Hi, In your
writing angularjs hello world program
writing 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 Tutorials
AngularJS 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 log4j programatically
Updating log4j programatically  Is there a ready made utility which I can use to edit the log4j.xml programmatically
updating & deleting an employee
updating & deleting an employee  can anyone help out me please? advance thanks warm regards
org.webjars - angularjs version 1.5.3 Maven dependency. How to use angularjs version 1.5.3 in pom.xml?
the step by step tutorial for using the latest version of org.webjars - angularjs...org.webjars  - Version 1.5.3 of angularjs Maven dependency? How to use  org.webjars  - Version 1.5.3 of angularjs in pom.xml? How to use
org.webjars - angularjs version 2.0.0-alpha.19 Maven dependency. How to use angularjs version 2.0.0-alpha.19 in pom.xml?
by step tutorial for using the latest version of org.webjars - angularjs in your...org.webjars  - Version 2.0.0-alpha.19 of angularjs Maven dependency? How to use  org.webjars  - Version 2.0.0-alpha.19 of angularjs in pom.xml
org.webjars - angularjs version 1.2.14 Maven dependency. How to use angularjs version 1.2.14 in pom.xml?
org.webjars  - Version 1.2.14 of angularjs Maven dependency? How to use  org.webjars  - Version 1.2.14 of angularjs in pom.xml? How to use angularjs version 1.2.14 in pom.xml? Learn to use this dependency in your project
org.webjars - angularjs version 1.2.18 Maven dependency. How to use angularjs version 1.2.18 in pom.xml?
org.webjars  - Version 1.2.18 of angularjs Maven dependency? How to use  org.webjars  - Version 1.2.18 of angularjs in pom.xml? How to use angularjs version 1.2.18 in pom.xml? Learn to use this dependency in your project
org.webjars - angularjs version 1.2.28 Maven dependency. How to use angularjs version 1.2.28 in pom.xml?
org.webjars  - Version 1.2.28 of angularjs Maven dependency? How to use  org.webjars  - Version 1.2.28 of angularjs in pom.xml? How to use angularjs version 1.2.28 in pom.xml? Learn to use this dependency in your project
Updating multiple value depending on checkboxes
Updating 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 - SQL
updating 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
Maven dependency for org.webjars - angularjs version 1.8.2 is released. Learn to use angularjs version 1.8.2 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.8.2 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.8.2. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.4.3-1 is released. Learn to use angularjs version 1.4.3-1 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.4.3-1 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.4.3-1. Developer can use
Maven dependency for org.webjars - angularjs version 1.4.0-rc.0 is released. Learn to use angularjs version 1.4.0-rc.0 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.4.0-rc.0 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.4.0-rc.0. Developer can use
Maven dependency for org.webjars - angularjs version 1.4.4 is released. Learn to use angularjs version 1.4.4 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.4.4 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.4.4. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.2.20 is released. Learn to use angularjs version 1.2.20 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.2.20 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.2.20. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.6.0 is released. Learn to use angularjs version 1.6.0 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.6.0 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.6.0. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.8.0 is released. Learn to use angularjs version 1.8.0 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.8.0 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.8.0. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.7.2 is released. Learn to use angularjs version 1.7.2 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.7.2 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.7.2. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.2.13 is released. Learn to use angularjs version 1.2.13 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.2.13 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.2.13. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.5.11 is released. Learn to use angularjs version 1.5.11 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.5.11 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.5.11. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.2.26 is released. Learn to use angularjs version 1.2.26 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.2.26 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.2.26. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.0.3 is released. Learn to use angularjs version 1.0.3 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.0.3 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.0.3. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.6.1 is released. Learn to use angularjs version 1.6.1 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.6.1 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.6.1. Developer can use this version
Maven dependency for org.webjars - angularjs version 1.2.10 is released. Learn to use angularjs version 1.2.10 in Maven based Java projects
Maven dependency for  org.webjars  - Version 1.2.10 of angularjs released The developers of   org.webjars - angularjs project have... of  org.webjars - angularjs library is 1.2.10. Developer can use
Updating user profile
Updating 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
Updating from MySQL 5.0 to 5.5 cPanel
Updating from MySQL 5.0 to 5.5 cPanel   Updating from MySQL 5.0 to 5.5 cPanel
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 - Hibernate
Problem 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
Maven Repository/Dependency: org.webjars | angularjs
Maven Repository/Dependency of Group ID org.webjars and Artifact ID angularjs. Latest version of org.webjars:angularjs dependencies. # Version Release Date 1 1.8.3 13
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
Starting MySQL.. ERROR! The server quit without updating PID file
Starting MySQL.. ERROR! The server quit without updating PID file  I...: Starting MySQL.. ERROR! The server quit without updating PID file (/var/lib... on disk using following command: fdisk -h and found there is no space
updating an access database with visual basic 2010
updating 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 date
updating 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 app
Ios 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
how to code-updating some details n some details r unchanged
how to code-updating some details n some details r unchanged  i have... the update query,but with that query all the details are updating... my doubt... are using? Specify it.   jsp,jdbc,sybase   i m using jsp,jdbc
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
Starting MySQL.The server quit without updating PID file
Starting MySQL.The server quit without updating PID file  Starting MySQL.The server quit without updating PID file (/var/lib/mysql/xxxxxx.pid
Starting MySQL....The server quit without updating PID file
Starting MySQL....The server quit without updating PID file  Hi, My... error: Starting MySQL....The server quit without updating PID file (/var/lib/mysql/xxxxx.pid). MySQL Restart fails and the server quit without updating PID

Ads