Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<style>
body{font-family:Arial;}

table{
border-collapse:collapse;
}

td{
border:1px solid black;
padding:5px;
}

th{
border:1px solid black;
padding:5px;
text-align:left;

.arrow-up{
	width:0;
	height:0;
	border-left:5px solid transparent;
	border-right:5px solid transparent;
	border-bottom:10px solid black;
	display:inline-block;
}

.arrow-down{
	width:0;
	height:0;
	border-left:5px solid transparent;
	border-right:5px solid transparent;
	border-top:10px solid black;
	display:inline-block;
}
}
</style>
<script>
var myApp=angular
			.module("myModule",[])
			.controller("myController",function ($scope){
			
			var employee=
			[
				{name:"Channel1"},
				{name:"Channel2"},
				{name:"Channel3"},
				{name:"Channel4"},
				{name:"Channel5"},
				{name:"Channel6"},
				{name:"Channel7"},
				{name:"Channel8"},
			]
			$scope.employee=employee;
			//$scope.rowLimit=3;
			//$scope.sortColumn="name";
			
			});
</script>

<body ng-app="myModule">
<div>
<b><h1>Sorting Data</h1></b>
</div>

<div ng-controller="myController">

<table>
<thead>
<tr>

<th>All Channels</th>

</tr>
</thead>

<tbody>
<tr ng-repeat="empl in employee">
<td >{{empl.name}}</td>
<td><button value="Select">Select</button></td>
</tr>
</tbody>

</table>
</div>
</body>
</html>


I want to hide the td which is clicked and show that td at the bottom with the same values but the button text will be unselect.

What I have tried:

I have tried the same with the div but not able to do the same in case of table
Posted
Updated 28-Feb-16 1:12am

1 solution

Hey there,

did you have a look at ng-show and ng-hide: https://docs.angularjs.org/api/ng/directive/ngShow[^]?


This way, you could hide the selected employee in your table:


HTML
<tbody>
    <tr ng-repeat="empl in employee" ng-hide="{{empl.selected}}">
        <td>{{empl.name}}</td>
        <td><button value="Select">Select</button></td>
    </tr>
</tbody>

Then you could add a click handler for your button that sets the employee's selected attribute.


Hope this helps. If you have further questions, let me know.
–Konstantin

 
Share this answer
 
Comments
Member 9423565 29-Feb-16 23:09pm    
Hi Konstantin

Thanks for your reply but I have tried ng-show and ng-hide but could not come up with the solution, if you could help me out in this as I am new to the angularjs that's why I am facing problem.
Konstantin A. Magg 2-Mar-16 1:35am    
Hey there,
learning AngularJS shouldn't be that tough ;)
At which point are you struggling with ng-hide?
-Konstantin

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900