Angularjs Inline Edit example – AngularJs update and save table Row Examples

Angularjs Inline Edit example – AngularJs update and save table Row Examples

In this Post We Will Explain About is Angularjs Inline Edit example With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to AngularJs update and save table Row ExamplesExample

In this post we will show you Best way to implement Edit row in angularjs table, hear for Creating simple inline editing with AngularJSwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!. I have the following angularjs Simple table with an edit button and save Button Examples

READ :  VueJs dynamic table rows - Add and Delete Rows dynamically using VueJs

Include Script and Module

 <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
 var liveApp = angular.module("liveApp", []);

Json Data using Angularjs

 $scope.clientList = [{'id':11, 'clientname':'mayur','place':'USA'}, {'id':10, 'clientname':'Kelly','place':'Australia'}, {'id':1, 'clientname':'Rimmy','place':'India'}, {'id':101, 'clientname':'Kat','place':'Serbia'}, {'id':190, 'clientname':'Yesha','place':'Srilanka'}, {'id':189, 'clientname':'Robert','place':'India'}];

Angularjs Custom Add Template

<script type="text/ng-template" id="view">
	<td>{{mydata.clientname}}</td><td>{{mydata.place}}</td> 
	<td>
		<button ng-click="editContent(mydata)">Edit</button>
	</td>
</script>

<script type="text/ng-template" id="edit">
	<td> <input type="text" ng-model="updaterow.clientname" /></td>
	<td> <input type="text" ng-model="updaterow.place" /></td>
	<td>
		<button ng-click="saveData($index)">Save</button>
		<button ng-click="reset()">Cancel</button>
	</td>
</script>

Full Example of Angularjs Inline Edit example

<!DOCTYPE html>
<html lang="en">
<head>
<title>AngularJs update table Row and Edit Row and Modify Row Example </title>
 <script src="angular.min.js"></script>
 <script>
var liveApp = angular.module("liveApp", []);
 liveApp.controller("liveCtrl", function($scope) {
 $scope.updaterow = '';
 
 $scope.clientList = [{'id':11, 'clientname':'mayur','place':'USA'}, {'id':10, 'clientname':'Kelly','place':'Australia'}, {'id':1, 'clientname':'Rimmy','place':'India'}, {'id':101, 'clientname':'Kat','place':'Serbia'}, {'id':190, 'clientname':'Yesha','place':'Srilanka'}, {'id':189, 'clientname':'Robert','place':'India'}];
  $scope.editContent = function(mydata) { 
        $scope.updaterow = angular.copy(mydata);   
	
 }
 $scope.loadTemplate = function(mydata) { 
    if (mydata.id === $scope.updaterow.id) return 'edit';
        else return 'view';
 }
 $scope.saveData = function (indx) {
        $scope.clientList[indx] = angular.copy($scope.updaterow);
        $scope.reset();
    };
$scope.reset = function(){
$scope.updaterow = [];
}
});
</script>
</head>
<body>  
<div ng-app="liveApp">  
<div ng-controller="liveCtrl">
<span style='color:green;font-weight:bold;'>{{message}}</span> 
<table border="2">
<tr><th>ClientName</th><th>Places</th><th>Actions</th></tr>

<tr ng-repeat="mydata in clientList" ng-include="loadTemplate(mydata)">
</tr>
</table>
<script type="text/ng-template" id="view">
	<td>{{mydata.clientname}}</td><td>{{mydata.place}}</td> 
	<td>
		<button ng-click="editContent(mydata)">Edit</button>
	</td>
</script>

<script type="text/ng-template" id="edit">
	<td> <input type="text" ng-model="updaterow.clientname" /></td>
	<td> <input type="text" ng-model="updaterow.place" /></td>
	<td>
		<button ng-click="saveData($index)">Save</button>
		<button ng-click="reset()">Cancel</button>
	</td>
</script>

</div> 
</div>

</body>  
</html>         

Example

READ :  C# Extension Methods Tutorial with Examples

I hope you have Got What is Creating simple inline editing with AngularJS or AngularJs update and save table Row Examples And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Add a Comment

Your email address will not be published. Required fields are marked *