1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
<!doctype html>
<html ng-app>
<head>
<title>Les Scope et Controller</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<meta charset="UTF-8">
</head>
<body ng-app="myApp">
<input type="text" ng-model="query">
<select ng-model="order">
<option value="-username">Organiser par nom</option>
<option value="content">Organiser par contenu</option>
</select>
<div ng-controller="CommentsCtrl">
<ul>
<div ng-repeat="comment in comments | filter:{content:query} | orderBy:order">
<p><strong>{{comment.username}}</strong><br>
{{comment.content}}
{{comment.email}}</p>
</div>
</ul>
</div>
<script>
var myApp = angular.module('myApp',[]);
myApp.controller('CommentsCtrl', ['$scope', function($scope){
$scope.comments = [
{
"username":"Dillon",
"city":"Nile",
"email":"dillonwelch@furnigger.com",
"content":"elit sint excepteur pariatur coluptate"
},
{
"username":"Anthony",
"city":"PALERMO",
"email":"anthony.palermo@gmail.com",
"content":"lorem ipsum dolor sit amet"
},
{
"username":"Jale",
"city":"Ankara",
"email":"jale.yildirim@hotmail.fr",
"content":"ipsum sit amet dolor"
},
{
"username":"Goku",
"city":"Planète Vegeta",
"email":"ssjblue@dbz.org",
"content":"tu as l'air très fort"
}
];
}]);
</script>
</body>
</html> |
Partager