Insert, Update and Delete in AngularJS – CRUD Operation
Dynamically Add/Remove rows in HTML table using Angularjs
we may also need to create dynamically one or more new rows on demand from code.This demo shows how to add a table row dynamically.
we may also need to create dynamically one or more new rows on demand from code.This demo shows how to add a table row dynamically.
var app = angular.module("myapp", []);
app.controller("liveCtrl", ['$scope', function($scope) {
$scope.ClientDetails = [
{
'fname':'Modi',
'lname':'Sachin',
'email':'Modi@Sachin.com'
},
{
'fname':'Rahul',
'lname':'Gandhi',
'email':'Rahul@Gandhi.com'
},
{
'fname':'Ravi',
'lname':'Dhameliya',
'email':'Ravi@Dhameliya.com'
}];
$scope.addNew = function(personalDetail){
$scope.ClientDetails.push({
'fname': "",
'lname': "",
'email': "",
});
};
$scope.remove = function(){
var newDataList=[];
$scope.selectedAll = false;
angular.forEach($scope.ClientDetails, function(selected){
if(!selected.selected){
newDataList.push(selected);
}
});
$scope.ClientDetails = newDataList;
};
$scope.checkAll = function () {
if (!$scope.selectedAll) {
$scope.selectedAll = true;
} else {
$scope.selectedAll = false;
}
angular.forEach($scope.ClientDetails, function(personalDetail) {
personalDetail.selected = $scope.selectedAll;
});
};
}]);