Skip to content

Instantly share code, notes, and snippets.

@anonymoussc
Created October 25, 2015 15:27
Using ng-hide on the Table Rows
<!DOCTYPE html>
<html ng-app="exampleApp">
<head>
<title>Directives</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
<script>
angular.module("exampleApp", [])
.controller("defaultCtrl", function($scope) {
$scope.todos = [
{action: "Get groceries", complete: false},
{action: "Call plumber", complete: false},
{action: "Buy running shoes", complete: true},
{action: "Buy flowers", complete: false},
{action: "Call family", complete: false}];
});
</script>
<style>
td > *:first-child {
font-weight : bold
}
</style>
</head>
<body>
<div id="todoPanel" class="panel" ng-controller="defaultCtrl">
<h3 class="panel-header">To Do List</h3>
<div class="checkbox well">
<label>
<input type="checkbox" ng-model="todos[2].complete"/>
Item 3 is complete
</label>
</div>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Action</th>
<th>Done</th>
</tr>
</thead>
<tr ng-repeat="item in todos" ng-hide="item.complete">
<td>{{$index + 1}}</td>
<td>{{item.action}}</td>
<td>{{item.complete}}</td>
</tr>
</table>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment