Skip to content

Instantly share code, notes, and snippets.

@davinkevin
Created February 16, 2016 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davinkevin/7ca8f182e1f2002e2f3d to your computer and use it in GitHub Desktop.
Save davinkevin/7ca8f182e1f2002e2f3d to your computer and use it in GitHub Desktop.
<!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