aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--example/personalLog/personalLog.html2
-rw-r--r--example/personalLog/personalLog.js22
2 files changed, 20 insertions, 4 deletions
diff --git a/example/personalLog/personalLog.html b/example/personalLog/personalLog.html
index 85a177e9..64a6115d 100644
--- a/example/personalLog/personalLog.html
+++ b/example/personalLog/personalLog.html
@@ -18,7 +18,7 @@
<hr/>
<h2>Logs:</h2>
<ul>
- <li ng:repeat="log in logs">
+ <li ng:repeat="log in logs.$orderBy('-at')">
{{log.at | date:'yy-MM-dd HH:mm'}} {{log.msg}}
[<a href="" ng:click="rmLog($index)">x</a>]
</li>
diff --git a/example/personalLog/personalLog.js b/example/personalLog/personalLog.js
index dbd0956f..c0273036 100644
--- a/example/personalLog/personalLog.js
+++ b/example/personalLog/personalLog.js
@@ -1,5 +1,20 @@
-//app namespace
-var example = {};
+/**
+ * @fileOverview Very simple personal log demo application to demostrate angular functionality,
+ * especially:
+ * - the MVC model
+ * - testability of controllers
+ * - dependency injection for controllers via $inject and constructor function
+ * - $cookieStore for persistent cookie-backed storage
+ * - simple templating constructs such as ng:repeat and {{}}
+ * - date filter
+ * - and binding onSubmit and onClick events to angular expressions
+ * @author Igor Minar
+ */
+
+
+/** @namespace the 'example' namespace */
+var example = example || {};
+/** @namespace namespace of the personal log app */
example.personalLog = {};
@@ -13,11 +28,12 @@ var LOGS = 'logs';
*/
function LogCtrl($cookieStore) {
var self = this,
- logs = self.logs = $cookieStore.get(LOGS) || [];
+ logs = self.logs = $cookieStore.get(LOGS) || []; //main model
/**
* Adds newMsg to the logs array as a log, persists it and clears newMsg.
+ * @param {string} msg Message to add (message is passed as parameter to make testing easier).
*/
this.addLog = function(msg) {
var newMsg = msg || self.newMsg;
a> 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279