Skip to content

Commit 6042276

Browse files
committed
A couple of small tweaks
1 parent ff87f18 commit 6042276

File tree

5 files changed

+28
-26
lines changed

5 files changed

+28
-26
lines changed

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,13 +536,13 @@ <h4 class="exercise-start">
536536
<h2 id="application-logic">Application Logic</h2>
537537
<p>In this chapter you’ll learn how to add JavaScript logic to your app, how to create services that talk to backend endpoints, and how to architect an app that uses multiple pages. There’s a lot to cover, so let’s start by discussing how to handle events and data binding.</p>
538538
<h3 id="events">Events</h3>
539-
<p>Most user interfaces are driven by events. In NativeScript apps, those events are usually some user action, such as tapping, swiping, or rotating—and NativeScript abstracts the iOS- and Android-specific code for handling such events into a handful of easy-to-use APIs. Let’s start with the most common event you’ll use in a NativeScript app<code>tap</code>.</p>
539+
<p>Most user interfaces are driven by events. In NativeScript apps, those events are usually some user action, such as tapping, swiping, or rotating—and NativeScript abstracts the iOS- and Android-specific code for handling such events into a handful of easy-to-use APIs. Let’s start with the most common event you’ll use in a NativeScript app: <code>tap</code>.</p>
540540
<h4 class="exercise-start">
541541
<b>Exercise</b>: Add a <code>tap</code> event handler
542542
</h4>
543543

544544
<p>Open <code>app/app.component.ts</code>, find the existing sign in button within your component’s <code>template</code> (<code>&lt;Button text=&quot;Sign in&quot;&gt;&lt;/Button&gt;</code>), and replace it with the following code:</p>
545-
<pre><code class="lang-JavaScript">&lt;Button text=&quot;Sign in&quot; (tap)=&quot;signIn()&quot;&gt;&lt;/Button&gt;
545+
<pre><code class="lang-JavaScript">&lt;Button text=&quot;Sign in&quot; id=&quot;submit-button&quot; (tap)=&quot;signIn()&quot;&gt;&lt;/Button&gt;
546546
</code></pre>
547547
<p>Next, in the same file, replace the current <code>AppComponent</code> declaration with the one shown below:</p>
548548
<pre><code class="lang-JavaScript">export class AppComponent {
@@ -554,16 +554,16 @@ <h4 class="exercise-start">
554554
<div class="exercise-end"></div>
555555

556556
<p>The <code>(eventName)=&quot;functionName()&quot;</code> syntax is part of <a href="https://angular.io/docs/ts/latest/guide/template-syntax.html#!#event-binding">Angular 2’s event binding system</a>, which lets you bind an event that occurs on a UI element to a function in your component’s class. In this case, the <code>(tap)=&quot;signIn()&quot;</code> syntax tells Angular to run the <code>AppComponent</code> class’s <code>signIn()</code> function whenever the user taps the sign in button.</p>
557-
<p>To verify this binding works try tapping the sign in button in your app; you should see “hello” logged in your terminal or command prompt as such:</p>
558-
<p><img src="images/chapter3/terminal-1.png" alt="Terminal showing the word hello logged"></p>
557+
<p>To verify this binding works tap the “Sign In” button in your app; you should see “hello” logged in your terminal or command prompt as such:</p>
558+
<p><img alt="Terminal showing the word hello logged" src="images/chapter3/terminal-1.png" class="plain"></p>
559559
<blockquote>
560560
<p><strong>TIP</strong>:</p>
561561
<ul>
562562
<li>In NativeScript you can find a list of events available in the appropriate UI element’s API documentation. For instance, the <a href="http://docs.nativescript.org/ApiReference/ui/button/Button">button element’s API documentation</a> lists its <code>tap</code> event.</li>
563563
<li>The Angular 2 docs have a helpful <a href="https://angular.io/docs/ts/latest/guide/cheatsheet.html">cheat sheet</a> that includes the various syntaxes available when building templates. Don’t worry too much about knowing how all these work at the moment; we’ll progressively introduce the most common syntaxes in this guide.</li>
564564
</ul>
565565
</blockquote>
566-
<p>With the <code>tap</code> event in place, we now have a way of tying our UI elements in our template to TypeScript code. To make a login page actually work though, we need to introduce one other way of connecting a template to code: data binding.</p>
566+
<p>With the <code>tap</code> event in place, you now have a way of tying the UI elements in your template to your TypeScript code. To make a login page actually work though, we need to introduce one other way of connecting a template to code: data binding.</p>
567567
<h3 id="data-binding">Data Binding</h3>
568568
<p>Angular 2 provides several ways to bind data in your TypeScript code to UI controls, and through the magic of NativeScript those same methods are available in your iOS and Android apps.</p>
569569
<p>The first of these is a way to bind UI attributes to properties defined in your TypeScript class. Let’s look at how it works.</p>
@@ -572,7 +572,7 @@ <h4 class="exercise-start">
572572
</h4>
573573

574574
<p>In <code>app/app.component.ts</code> replace the current <code>AppComponent</code> declaration with the one shown below, which adds a new <code>email</code> property, and changes the <code>signIn()</code> method to display its value:</p>
575-
<pre><code class="lang-JavaScript">export class AppComponent {
575+
<pre><code class="lang-TypeScript">export class AppComponent {
576576
email = &quot;nativescriptrocks@telerik.com&quot;;
577577
signIn() {
578578
alert(&quot;You’re using: &quot; + this.email);

scripts/built.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/chapters/chapter3.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ In this chapter you’ll learn how to add JavaScript logic to your app, how to c
44

55
### Events
66

7-
Most user interfaces are driven by events. In NativeScript apps, those events are usually some user action, such as tapping, swiping, or rotating—and NativeScript abstracts the iOS- and Android-specific code for handling such events into a handful of easy-to-use APIs. Let’s start with the most common event you’ll use in a NativeScript app`tap`.
7+
Most user interfaces are driven by events. In NativeScript apps, those events are usually some user action, such as tapping, swiping, or rotating—and NativeScript abstracts the iOS- and Android-specific code for handling such events into a handful of easy-to-use APIs. Let’s start with the most common event you’ll use in a NativeScript app: `tap`.
88

99
<h4 class="exercise-start">
1010
<b>Exercise</b>: Add a `tap` event handler
@@ -13,7 +13,7 @@ Most user interfaces are driven by events. In NativeScript apps, those events ar
1313
Open `app/app.component.ts`, find the existing sign in button within your component’s `template` (`<Button text="Sign in"></Button>`), and replace it with the following code:
1414

1515
``` JavaScript
16-
<Button text="Sign in" (tap)="signIn()"></Button>
16+
<Button text="Sign in" id="submit-button" (tap)="signIn()"></Button>
1717
```
1818

1919
Next, in the same file, replace the current `AppComponent` declaration with the one shown below:
@@ -30,15 +30,15 @@ export class AppComponent {
3030

3131
The `(eventName)="functionName()"` syntax is part of [Angular 2’s event binding system](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#event-binding), which lets you bind an event that occurs on a UI element to a function in your component’s class. In this case, the `(tap)="signIn()"` syntax tells Angular to run the `AppComponent` class’s `signIn()` function whenever the user taps the sign in button.
3232

33-
To verify this binding works try tapping the sign in button in your app; you should see “hello” logged in your terminal or command prompt as such:
33+
To verify this binding works tap the “Sign In” button in your app; you should see “hello” logged in your terminal or command prompt as such:
3434

35-
![Terminal showing the word hello logged](images/chapter3/terminal-1.png)
35+
<img alt="Terminal showing the word hello logged" src="images/chapter3/terminal-1.png" class="plain">
3636

3737
> **TIP**:
3838
> * In NativeScript you can find a list of events available in the appropriate UI element’s API documentation. For instance, the [button element’s API documentation](http://docs.nativescript.org/ApiReference/ui/button/Button) lists its `tap` event.
3939
> * The Angular 2 docs have a helpful [cheat sheet](https://angular.io/docs/ts/latest/guide/cheatsheet.html) that includes the various syntaxes available when building templates. Don’t worry too much about knowing how all these work at the moment; we’ll progressively introduce the most common syntaxes in this guide.
4040
41-
With the `tap` event in place, we now have a way of tying our UI elements in our template to TypeScript code. To make a login page actually work though, we need to introduce one other way of connecting a template to code: data binding.
41+
With the `tap` event in place, you now have a way of tying the UI elements in your template to your TypeScript code. To make a login page actually work though, we need to introduce one other way of connecting a template to code: data binding.
4242

4343
### Data Binding
4444

@@ -52,7 +52,7 @@ The first of these is a way to bind UI attributes to properties defined in your
5252

5353
In `app/app.component.ts` replace the current `AppComponent` declaration with the one shown below, which adds a new `email` property, and changes the `signIn()` method to display its value:
5454

55-
``` JavaScript
55+
``` TypeScript
5656
export class AppComponent {
5757
email = "nativescriptrocks@telerik.com";
5858
signIn() {

src/scripts/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"c#": "clike",
4848
"appbuilder" : "javascript",
4949
"javascript" : "javascript",
50-
"typescript" : "javascript",
50+
"typescript" : "typescript",
5151
"c++" : "clike",
5252
"c" : "clike",
5353
"css" : "css",

0 commit comments

Comments
 (0)