How to add row dynamically in table using angularjs

Posted by Klbaiju under AngularJS 1x on 7/25/2018 | Points: 10 | Views : 2629 | Status : [Member] | Replies : 1
Hi,

Following is my working code for adding a row in atable using angularjs

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function ($scope, $http) {
debugger;
$scope.InsertEmp = function (Emp) {
$scope.Message = null;
$scope.Emp = {};
$scope.Emp.FirstName=$scope.FirstName;
$scope.Emp.LastName = $scope.LastName;
$scope.Emp.Company = $scope.Company;

$http({
method: "post",
url: "/Home/Insert",
data: JSON.stringify($scope.Emp)
}).then(function (response) {

if (response.data == 'Employee Added Successfully') {
$scope.FirstName = null;
$scope.LastName = null;
$scope.Company = null;
$scope.Message = "Record Added Successfully";
$scope.myStyle = { color: "green", background: "white" }
}
else {
$scope.Message = "Record Not Added";
$scope.myStyle = { color: "red", background: "white" }

}


})

};

});
</script>

My requirement is to display the current record in the table as last record.

ie the table already contains some records

I want to display the current record in the last row

code should be inside the following code

if (response.data == 'Employee Added Successfully') {

$scope.FirstName = null;
$scope.LastName = null;
$scope.Company = null;
$scope.Message = "Record Added Successfully";
$scope.myStyle = { color: "green", background: "white" } }

how it is possible


Regards

Baiju




Responses

Posted by: Swappy_Gaj on: 9/17/2018 [Member] Starter | Points: 25

Up
0
Down
O through below link:
1.https://scotch.io/tutorials/sort-and-filter-a-table-using-angular

2.http://jsfiddle.net/vojtajina/js64b/14/

Klbaiju, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response