Skip to content

Instantly share code, notes, and snippets.

@rohman
Created June 5, 2013 11:43
Show Gist options
  • Save rohman/5713316 to your computer and use it in GitHub Desktop.
Save rohman/5713316 to your computer and use it in GitHub Desktop.
Contoh penggunaan ng-filter & ng-repeat
<!DOCTYPE html>
<html>
<head>
<title>Angular Binding</title>
<link rel="stylesheet" href="assets/foundation/foundation.css" />
</head>
<body>
<div ng-app="MyApp">
<div ng-controller="AvengerCtrl">
<input type="text" ng-model="search.$"/>
<table>
<tr>
<th>Nama</th>
<th>Character</th>
</tr>
<tr ng-repeat="avenger in avengers.player | filter:search">
<td>{{avenger.name}}</td>
<td>{{avenger.character}}</td>
</tr>
</table>
</div>
</div>
<script type="text/javascript" src="assets/angularjs/angular.js"></script>
<script type="text/javascript">
var myApp = angular.module("MyApp", []);
myApp.factory("Avengers", function(){
var Avengers ={};
Avengers.player=[
{name: 'Syahril Rohman', character:'Superman'},
{name: 'Rohman', character:'Spiderman'},
{name: 'Rohman syahril', character:'Hulk'},
{name: 'Peter', character:'Iron Man'},
{name: 'Debi', character:'Spiderman III'},
];
return Avengers;
});
myApp.controller("AvengerCtrl", function($scope, Avengers){
$scope.avengers = Avengers;
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment