Skip to content

Commit 530ffd7

Browse files
committed
Starting in on chapter 4
1 parent edd5f52 commit 530ffd7

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

index.html

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,7 +939,36 @@ <h4 class="exercise-start">
939939
</div>
940940
<div class="chapter">
941941
<h2 id="nativescript-modules">NativeScript modules</h2>
942-
<h3 id="dialog">Dialog</h3>
942+
<p>Explain what modules are. Should be able to copy content almost verbatim from the current guide.</p>
943+
<h3 id="ui-elements">UI elements</h3>
944+
<p>Explain that UI elements are actually NativeScript modules.</p>
945+
<h4 class="exercise-start">
946+
<b>Exercise</b>: ???
947+
</h4>
948+
949+
<p>In app/pages/login/login.component.ts, first add these imports:</p>
950+
<pre><code class="lang-TypeScript">import {topmost} from &quot;ui/frame&quot;;
951+
import {Page} from &quot;ui/page&quot;;
952+
</code></pre>
953+
<p>Then include <code>OnInit</code> in the existing <code>&quot;angular2/core&quot;</code> import:</p>
954+
<pre><code class="lang-TypeScript">import {Component, OnInit} from &quot;angular2/core&quot;;
955+
</code></pre>
956+
<p>Add the following as a new property in the <code>LoginPage</code> class:</p>
957+
<pre><code class="lang-TypeScript">page: Page;
958+
</code></pre>
959+
<p>Then add the following function to the <code>LoginPage</code> class:</p>
960+
<pre><code class="lang-TypeScript">ngOnInit() {
961+
this.page = &lt;Page&gt;topmost().currentPage;
962+
this.page.actionBarHidden = true;
963+
this.page.backgroundImage = this.page.ios ? &quot;res://bg_login.jpg&quot; : &quot;res://bg_login&quot;;
964+
}
965+
</code></pre>
966+
<blockquote>
967+
<p><strong>NOTE</strong>: The <code>this.page.ios</code> check can go away in 2.0. It’s there because of <a href="https://github.com/NativeScript/NativeScript/issues/1788">this bug</a>.</p>
968+
</blockquote>
969+
<div class="exercise-end"></div>
970+
971+
<p>Explain what <code>OnInit</code> is. Explain how to look up {N} modules on the docs. Show images of what the app looks like now. Transition to talking about the list page.</p>
943972
<h3 id="listview">ListView</h3>
944973
<h3 id="gridlayout">GridLayout</h3>
945974
<h3 id="activityindicator">ActivityIndicator</h3>

src/chapters/chapter4.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,49 @@
11
## NativeScript modules
22

3-
### Dialog
3+
Explain what modules are. Should be able to copy content almost verbatim from the current guide.
4+
5+
### UI elements
6+
7+
Explain that UI elements are actually NativeScript modules.
8+
9+
<h4 class="exercise-start">
10+
<b>Exercise</b>: ???
11+
</h4>
12+
13+
In app/pages/login/login.component.ts, first add these imports:
14+
15+
``` TypeScript
16+
import {topmost} from "ui/frame";
17+
import {Page} from "ui/page";
18+
```
19+
20+
Then include `OnInit` in the existing `"angular2/core"` import:
21+
22+
```TypeScript
23+
import {Component, OnInit} from "angular2/core";
24+
```
25+
26+
Add the following as a new property in the `LoginPage` class:
27+
28+
``` TypeScript
29+
page: Page;
30+
```
31+
32+
Then add the following function to the `LoginPage` class:
33+
34+
``` TypeScript
35+
ngOnInit() {
36+
this.page = <Page>topmost().currentPage;
37+
this.page.actionBarHidden = true;
38+
this.page.backgroundImage = this.page.ios ? "res://bg_login.jpg" : "res://bg_login";
39+
}
40+
```
41+
42+
> **NOTE**: The `this.page.ios` check can go away in 2.0. It’s there because of [this bug](https://github.com/NativeScript/NativeScript/issues/1788).
43+
44+
<div class="exercise-end"></div>
45+
46+
Explain what `OnInit` is. Explain how to look up {N} modules on the docs. Show images of what the app looks like now. Transition to talking about the list page.
447

548
### ListView
649

0 commit comments

Comments
 (0)