Create a gist now

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>{{ name }}</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.2.x" src="https://code.angularjs.org/1.2.16/angular.js" data-semver="1.2.16"></script>
<script src="app.js"></script>
</head>
<body ng-controller="MainCtrl as ctrl">
Le nom : <input type="text" ng-model="ctrl.name"> <button ng-click="ctrl.register()"> Show in Log </button>
<div ng-show="ctrl.name" >Hello {{ ctrl.name }}</div>
<input type="text" ng-model="ctrl.filter">
<div>Registered Users</div>
<table>
<thead>
<th>Name</th>
<th>Date</th>
</thead>
<tbody>
<tr ng-repeat="user in ctrl.users | filter: {name : ctrl.filter}">
<td>{{ user.name }}</td>
<td>{{ user.date | date | uppercase }}</td>
</tr>
</tbody>
</table>
</body>
</html>
// Déclaration de l'application : (Cf <html ng-app="plunker"> )
var app = angular.module('plunker', []);
// Déclaration d'un controller : (cf <body ng-controller="MainCtrl"> )
app.controller('MainCtrl', function($log) {
var vm = this;
vm.name = "Foo";
vm.users = [];
vm.register = function() {
vm.users.push({
name : vm.name,
date : Date.now()
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment