Transfer Row To Other Table Using AngularJS
Submitted by razormist on Thursday, July 9, 2020 - 14:47.
In this code we will tackle about Transfer Row To Other Table using AngularJS. The code will force the table row to transfer into other table. Feel free to use this code and modify as you learn from it. To learn more about this, just follow the steps below.
There you have it we successfully created a Transfer Row To Other Table using AngularJS. I hope that this very simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!
Getting started:
First you will need to download & install the AngularJS here's the link https://angularjs.org/. And this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.Creating the Main Interface
This code contains the interface of the application. This code will render application and display the form. To do that just kindly write these block of code inside the text editor and save this as index.html.- <!DOCTYPE html>
- <html lang="en" ng-app="myModule">
- <head>
- <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
- </head>
- <body ng-controller="myController">
- <nav class="navbar navbar-default">
- <div class="containet-fluid">
- </div>
- </nav>
- <div class="col-md-6 well">
- <hr style="border-top:1px dotted #ccc;"/>
- <div class="col-md-6">
- <table class="table table-bordered">
- <thead class="alert-info">
- <tr>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="member in members">
- </tr>
- </tbody>
- </table>
- </div>
- <div class="col-md-6">
- <table class="table table-bordered">
- <thead class="alert-info">
- <tr>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="member in members2">
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </body>
- </html>
Creating the Main Function
This code contains the main function of the application. The code will dynamically transfer a data to other table row. To that just kindly copy and write these block of codes inside the text editor, then save it inside the js folder as script.js- var app = angular.module("myModule", [])
- .controller("myController", function($scope){
- $scope.members = [
- {name: "John Smith", age: "21"},
- {name: "Claire Temple", age: "18"}
- ];
- $scope.members2 = [];
- $scope.transfer = function(member){
- $scope.members2.push(member);
- $scope.members.splice($scope.members.indexOf(member), 1);
- };
- });
Add new comment
- 153 views