Skip to content

Commit 73962e7

Browse files
committed
Updating 3.2 wording
1 parent 3ee34e5 commit 73962e7

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

index.html

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,14 @@ <h4 class="exercise-start">
611611
<p>At this point, you have a basic login screen setup with two-way data binding—not bad for 20 some lines of code of TypeScript. (Think about how much code you’d have to write in Android Studio <em>and</em> Xcode to accomplish the same task.) To this point though you’ve been placing all of your logic in a single TypeScript file, which doesn’t scale all that well for real-world applications.</p>
612612
<p>Before we tie this app to a backend and make this login screen fully functional, let’s take a step back and setup a structure that can scale.</p>
613613
<h3 id="structuring-your-app">Structuring your app</h3>
614-
<p>There are many reasons to segment any application into modular units, and you can <a href="https://en.wikipedia.org/wiki/Modular_programming">read about the various benefits on Wikipedia</a>. However, keeping NativeScript apps modular has one unique benefit: the ability to share the code you write between Angular-2-built web apps, and Angular-2-build native apps.</p>
615-
<p>Even if you have no plans to create an Angular 2 web app, separating out your code is still advantageous for a number of other reasons—testability, ease of maintenance, and so forth—but if you <em>do</em> have plans to build an Angular 2 web app, having a chunk of functionality that you can reuse for your native and web apps can be an invaluable time saver.</p>
616-
<p>To see how this works in action let’s edit some files in the <code>/shared</code> folder and set them up to be imported.</p>
614+
<p>There are many reasons to segment any application into modular units, and you can <a href="https://en.wikipedia.org/wiki/Modular_programming">read about the various benefits on Wikipedia</a>. However, keeping NativeScript apps modular has one unique benefit: the ability to share the code you write between Angular-2-built web apps, and Angular-2-built native apps.</p>
615+
<p>Even if you have no plans to create an Angular 2 web app, separating out your code is still advantageous for a number of other reasons—testability, ease of maintenance, and so forth—but if you <em>do</em> have plans to build an Angular 2 web app, having a chunk of functionality that you can reuse in your native and web apps can be an invaluable time saver.</p>
616+
<p>To see how this works in action, let’s edit some files in the <code>/shared</code> folder and set them up to be imported.</p>
617617
<h4 class="exercise-start">
618618
<b>Exercise</b>: Add a model object
619619
</h4>
620620

621-
<p>The first thing we’ll do is add a model object to store user data. Open <code>app/user/user.ts</code> and paste in the following code:</p>
621+
<p>Let’s start by creating a simple model object to store user data. Open <code>app/user/user.ts</code> and paste in the following code:</p>
622622
<pre><code class="lang-JavaScript">export class User {
623623
email: string;
624624
password: string;
@@ -628,7 +628,7 @@ <h4 class="exercise-start">
628628
<p>Next, open <code>app/app.component.ts</code>, and first add the following <code>import</code> to the top of the file:</p>
629629
<pre><code class="lang-JavaScript">import {User} from &quot;./shared/user/user&quot;;
630630
</code></pre>
631-
<p>Here you import the <code>User</code> class that you just defined. Note the parallel between the <code>export</code> command used in the previous example and the <code>import</code> command used in the previous example. The reason the <code>User</code> class is available to import is because it was explicitly exported. You’ll see other examples of <code>import</code> and <code>export</code> as you go through this guide.</p>
631+
<p>Here you import the <code>User</code> class that you just defined. Note the parallel between the <code>export</code> command used in the previous example and the <code>import</code> command used here. The reason the <code>User</code> class is available to import is because it was explicitly exported. You’ll see other examples of <code>import</code> and <code>export</code> as you go through this guide.</p>
632632
<p>Next, replace the existing <code>AppComponent</code> definition with the one below, which uses the <code>User</code> class you just imported.</p>
633633
<pre><code class="lang-JavaScript">export class AppComponent {
634634
user: User;
@@ -640,8 +640,11 @@ <h4 class="exercise-start">
640640
}
641641
}
642642
</code></pre>
643-
<p>Instead of storing data on the <code>AppComponent</code> directly, you’re now using the <code>User</code> model object, which is reusable outside of this page and even outside of this application. You also provide a TypeScript constructor, which is a function invoked when an instance of the <code>AppComponent</code> class is instantiated. In this app, Angular 2 instantiates an <code>AppComponent</code> for you with the call to <code>nativeScriptBootstrap(AppComponent)</code> done in <code>main.ts</code>. </p>
644-
<p>Your final step is to use this new model object in your template. To do that, replace the existing two <code>&lt;TextField&gt;</code>s with the code shown below, which updates the <code>[(ngModel)]</code> bindings to point at the new <code>User</code> object:</p>
643+
<p>Instead of storing data on the <code>AppComponent</code> directly, you’re now using the <code>User</code> model object, which is reusable outside of this page and even outside of this application. You instantiate a new instance of the <code>User</code> class in a new <code>constructor</code> function, that Angular 2 will invoke when it bootstraps your application.</p>
644+
<blockquote>
645+
<p><strong>NOTE</strong>: Remember that in <code>main.ts</code> you’re calling <code>nativeScriptBootstrap(AppComponent)</code>. Under the hood, Angular 2 will instantiate an instance of <code>AppComponent</code> during the bootstrapping process, which will cause your <code>AppComponent</code> constructor function to run.</p>
646+
</blockquote>
647+
<p>Your final step is to use this new model object in your template. To do that, replace the two existing <code>&lt;TextField&gt;</code>s with the code shown below, which updates the <code>[(ngModel)]</code> bindings to point at the new <code>User</code> object:</p>
645648
<pre><code class="lang-XML">&lt;TextField hint=&quot;Email Address&quot; keyboardType=&quot;email&quot; [(ngModel)]=&quot;user.email&quot;
646649
autocorrect=&quot;false&quot; autocapitalizationType=&quot;none&quot;&gt;&lt;/TextField&gt;
647650
&lt;TextField hint=&quot;Password&quot; secure=&quot;true&quot; [(ngModel)]=&quot;user.password&quot;&gt;&lt;/TextField&gt;

src/chapters/chapter3.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ Before we tie this app to a backend and make this login screen fully functional,
110110

111111
### Structuring your app
112112

113-
There are many reasons to segment any application into modular units, and you can [read about the various benefits on Wikipedia](https://en.wikipedia.org/wiki/Modular_programming). However, keeping NativeScript apps modular has one unique benefit: the ability to share the code you write between Angular-2-built web apps, and Angular-2-build native apps.
113+
There are many reasons to segment any application into modular units, and you can [read about the various benefits on Wikipedia](https://en.wikipedia.org/wiki/Modular_programming). However, keeping NativeScript apps modular has one unique benefit: the ability to share the code you write between Angular-2-built web apps, and Angular-2-built native apps.
114114

115-
Even if you have no plans to create an Angular 2 web app, separating out your code is still advantageous for a number of other reasons—testability, ease of maintenance, and so forth—but if you _do_ have plans to build an Angular 2 web app, having a chunk of functionality that you can reuse for your native and web apps can be an invaluable time saver.
115+
Even if you have no plans to create an Angular 2 web app, separating out your code is still advantageous for a number of other reasons—testability, ease of maintenance, and so forth—but if you _do_ have plans to build an Angular 2 web app, having a chunk of functionality that you can reuse in your native and web apps can be an invaluable time saver.
116116

117-
To see how this works in action let’s edit some files in the `/shared` folder and set them up to be imported.
117+
To see how this works in action, let’s edit some files in the `/shared` folder and set them up to be imported.
118118

119119
<h4 class="exercise-start">
120120
<b>Exercise</b>: Add a model object
121121
</h4>
122122

123-
The first thing we’ll do is add a model object to store user data. Open `app/user/user.ts` and paste in the following code:
123+
Let’s start by creating a simple model object to store user data. Open `app/user/user.ts` and paste in the following code:
124124

125125
``` JavaScript
126126
export class User {
@@ -137,7 +137,7 @@ Next, open `app/app.component.ts`, and first add the following `import` to the t
137137
import {User} from "./shared/user/user";
138138
```
139139

140-
Here you import the `User` class that you just defined. Note the parallel between the `export` command used in the previous example and the `import` command used in the previous example. The reason the `User` class is available to import is because it was explicitly exported. You’ll see other examples of `import` and `export` as you go through this guide.
140+
Here you import the `User` class that you just defined. Note the parallel between the `export` command used in the previous example and the `import` command used here. The reason the `User` class is available to import is because it was explicitly exported. You’ll see other examples of `import` and `export` as you go through this guide.
141141

142142
Next, replace the existing `AppComponent` definition with the one below, which uses the `User` class you just imported.
143143

@@ -153,9 +153,11 @@ export class AppComponent {
153153
}
154154
```
155155

156-
Instead of storing data on the `AppComponent` directly, you’re now using the `User` model object, which is reusable outside of this page and even outside of this application. You also provide a TypeScript constructor, which is a function invoked when an instance of the `AppComponent` class is instantiated. In this app, Angular 2 instantiates an `AppComponent` for you with the call to `nativeScriptBootstrap(AppComponent)` done in `main.ts`.
156+
Instead of storing data on the `AppComponent` directly, you’re now using the `User` model object, which is reusable outside of this page and even outside of this application. You instantiate a new instance of the `User` class in a new `constructor` function, that Angular 2 will invoke when it bootstraps your application.
157157

158-
Your final step is to use this new model object in your template. To do that, replace the existing two `<TextField>`s with the code shown below, which updates the `[(ngModel)]` bindings to point at the new `User` object:
158+
> **NOTE**: Remember that in `main.ts` you’re calling `nativeScriptBootstrap(AppComponent)`. Under the hood, Angular 2 will instantiate an instance of `AppComponent` during the bootstrapping process, which will cause your `AppComponent` constructor function to run.
159+
160+
Your final step is to use this new model object in your template. To do that, replace the two existing `<TextField>`s with the code shown below, which updates the `[(ngModel)]` bindings to point at the new `User` object:
159161

160162
``` XML
161163
<TextField hint="Email Address" keyboardType="email" [(ngModel)]="user.email"

0 commit comments

Comments
 (0)