Created
November 22, 2014 21:19
-
-
Save kalbarczyk/58553f4e05e1c66b3e20 to your computer and use it in GitHub Desktop.
AngularJS - ng-repeat + filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html data-ng-app="app"> | |
<head> | |
<title>AngularJS - ng-repeat + filter</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" /> | |
</head> | |
<body> | |
<div data-ng-controller="defaultCtrl"> | |
<input data-ng-model="text" class="form-control" /> {{text}} | |
<table class="table"> | |
<thead> | |
<tr> | |
<th>Mountain</th> | |
<th>Metres</th> | |
<th>Country</th> | |
</tr> | |
</thead> | |
<tbody> | |
<tr ng-repeat="mountain in mountainsList | filter:text"> | |
<td>{{mountain.mountain}}</td> | |
<td>{{mountain.metres}}</td> | |
<td>{{mountain.country}}</td> | |
</tr> | |
</tbody> | |
</table> | |
</div> | |
<script src="https://code.angularjs.org/1.3.0/angular.js"></script> | |
<script> | |
var app = angular.module('app', []); | |
app.controller('defaultCtrl', function ($scope) { | |
$scope.mountainsList = [ | |
{ mountain: "Mount Everest", metres: 8850, country: 'Nepal-China' }, | |
{ mountain: "K2", metres: 8611, country: 'Pakistan-China' }, | |
{ mountain: "Kangczendzonga", metres: 8598, country: 'Nepal-India' }, | |
{ mountain: "Lhotse", metres: 8501, country: 'Nepal-China' }, | |
{ mountain: "Makalu", metres: 8463, country: 'Nepal-China' } | |
]; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment