blob: 254dd08c7d585a75acb3a7ac234bfb46e28373e0 [file] [log] [blame]
Simon Hunt335b2472014-12-08 16:52:18 -08001<!DOCTYPE html>
2<html ng-app="notesApp">
3<head>
4 <title>Notes App</title>
5 <style>
6 .done {
7 background-color: limegreen;
8 }
9 .pending {
10 background-color: yellow;
11 }
12 .assignee {
13 color: red;
14 font-weight: bold;
15 }
16 </style>
17 <script src="../../tp/angular.js"></script>
18</head>
19<body ng-controller="MainCtrl as ctrl">
20
21 <div ng-repeat="note in ctrl.notes"
22 ng-class="ctrl.getNoteClass(note.done)">
23 <span class="label"> {{note.label}} </span>
24 <span class="assignee"
25 ng-show="note.assignee"
26 ng-bind="note.assignee">
27 </span>
28 </div>
29
30 <script type="text/javascript">
31 angular.module('notesApp', []).controller('MainCtrl', [
32 function () {
33 var self = this;
34 self.notes = [
35 {id: 1, label: 'First note', done: false, assignee: 'Simon'},
36 {id: 2, label: 'Second note', done: false},
37 {id: 3, label: 'Done note', done: true},
38 {id: 4, label: 'Last note', done: false, assignee: 'Fred'}
39 ];
40
41 self.getNoteClass = function (status) {
42 return {
43 done: status,
44 pending: !status
45 };
46 };
47 }
48 ]);
49 </script>
50
51</body>
52</html>