clarify controller in guide

This commit is contained in:
Leo Horie 2014-05-29 22:20:46 -04:00
parent 7cb6982e57
commit 16e6f6fdd5
3 changed files with 5 additions and 2 deletions

View file

@ -130,7 +130,8 @@ todo.controller = function() {
}
};
}</code></pre>
<p>The code above should hopefully be self-explanatory. You can use the controller like this:</p>
<p>The code above defines a controller class. It has three members: <code>list</code>, which is simply an array, <code>description</code>, which is an <code>m.prop</code> getter-setter function with an empty string as the initial value, and <code>add</code>, which is a method that adds a new Todo instance to <code>list</code> if an input description getter-setter is not an empty string. Later in this guide, we&#39;ll pass the <code>description</code> property as the parameter to this function. I&#39;ll explain why we&#39;re passing it as an argument when we get there.</p>
<p>You can use the controller like this:</p>
<pre><code class="lang-javascript">var ctrl = new todo.controller();
ctrl.description(); //[empty string]

Binary file not shown.

View file

@ -127,7 +127,9 @@ todo.controller = function() {
}
```
The code above should hopefully be self-explanatory. You can use the controller like this:
The code above defines a controller class. It has three members: `list`, which is simply an array, `description`, which is an `m.prop` getter-setter function with an empty string as the initial value, and `add`, which is a method that adds a new Todo instance to `list` if an input description getter-setter is not an empty string. Later in this guide, we'll pass the `description` property as the parameter to this function. I'll explain why we're passing it as an argument when we get there.
You can use the controller like this:
```javascript
var ctrl = new todo.controller();