mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
improving the PersonalLog app
- adding jsdocs and comments - logs should be ordered in inverse order
This commit is contained in:
parent
5b40e87ac6
commit
4fc2141458
2 changed files with 20 additions and 4 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue