Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 21704e9

Browse files
authored
Merge pull request #1811 from lex111/fix-typos
Improve docs
2 parents 1e44a0b + d8fecb4 commit 21704e9

20 files changed

+141
-139
lines changed

docs/cookbook/tab-view-ng.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export class DataItem {
112112
}
113113

114114
@Component({
115-
selector: "tab-view-test",
116-
templateUrl: "tab-view-test.html"
115+
selector: "tab-view-test",
116+
templateUrl: "tab-view-test.html"
117117
})
118118
export class TabViewTest {
119119
public items: Array<DataItem>;

docs/core-concepts/accessing-native-apis-with-javascript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ let array = new NSMutableArray();
149149
array.addObject(new NSObject());
150150
```
151151

152-
This snippet creates an instance of `NSMutableArray` and adds an object to it using the `addObject(object)` method. Here is what happens behind the curtains: the `new NSMutableArray()` call is translated to a `[[NSMutableArray alloc] init]` call by the iOS Runtime. This instance is then wrapped in a JavaScript object and stored in the `array` variable. It contains all public properties and methods exposed by `NSMutableArray` (and its base classes) in its prototype chain. While the `addObject(object)` call is straightforward, calling Objective-C methods with more arguments follows several simple rules that define how Objective-C selectors are mapped to JavaScript functions. Let's consider the following `NSMutableArray` selector: `replaceObjectsInRange:withObjectsFromArray:range:`. In JavaScript it is represented by the following function: `replaceObjectsInRangeWithObjectsFromArrayRange(objectsToRange, souceArray, sourceRange)` (argument names are arbitrary). Note that the function name is generated by appending the names of the arguments as defined by the Objective-C selector by starting with a small letter for the first argument and appending each subsequent with a capital letter.
152+
This snippet creates an instance of `NSMutableArray` and adds an object to it using the `addObject(object)` method. Here is what happens behind the curtains: the `new NSMutableArray()` call is translated to a `[[NSMutableArray alloc] init]` call by the iOS Runtime. This instance is then wrapped in a JavaScript object and stored in the `array` variable. It contains all public properties and methods exposed by `NSMutableArray` (and its base classes) in its prototype chain. While the `addObject(object)` call is straightforward, calling Objective-C methods with more arguments follows several simple rules that define how Objective-C selectors are mapped to JavaScript functions. Let's consider the following `NSMutableArray` selector: `replaceObjectsInRange:withObjectsFromArray:range:`. In JavaScript it is represented by the following function: `replaceObjectsInRangeWithObjectsFromArrayRange(objectsToRange, sourceArray, sourceRange)` (argument names are arbitrary). Note that the function name is generated by appending the names of the arguments as defined by the Objective-C selector by starting with a small letter for the first argument and appending each subsequent with a capital letter.
153153

154154
#### NSDictionary
155155

docs/core-concepts/angular-data-binding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ onButtonTap(args: EventData) {
4646

4747
> Before we can use the ngModel directive in a two-way data binding, we must import the **NativeScriptFormsModule** and add it to the Angular module's imports list:
4848
> ```typescript
49-
import {NativeScriptFormsModule} from "nativescript-angular/forms"
49+
import { NativeScriptFormsModule } from "nativescript-angular/forms"
5050
@NgModule({
5151
imports: [
5252
NativeScriptModule,

docs/core-concepts/angular-navigation.md

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ import { RouterExtensions } from "nativescript-angular/router";
6767
})
6868
export class MainComponent {
6969

70-
constructor(private routerExtensions: RouterExtensions) {
71-
}
70+
constructor(private routerExtensions: RouterExtensions) {
71+
}
7272
}
7373
```
7474

@@ -240,17 +240,17 @@ export class AppComponent { }
240240
import { Component, OnInit } from "@angular/core";
241241

242242
@Component({
243-
selector: "Hub",
244-
templateUrl: "./hub.component.html",
245-
styleUrls: ['./hub.component.css']
243+
selector: "Hub",
244+
templateUrl: "./hub.component.html",
245+
styleUrls: ['./hub.component.css']
246246
})
247247
export class HubComponent implements OnInit {
248248

249-
constructor() {
250-
}
249+
constructor() {
250+
}
251251

252-
ngOnInit(): void {
253-
}
252+
ngOnInit(): void {
253+
}
254254
}
255255
```
256256
```hub.component.html
@@ -268,21 +268,21 @@ import { Component, OnInit } from "@angular/core";
268268
import { Location } from "@angular/common";
269269

270270
@Component({
271-
selector: "Featured",
272-
templateUrl: "./featured.component.html",
273-
styleUrls: ['./featured.component.css']
271+
selector: "Featured",
272+
templateUrl: "./featured.component.html",
273+
styleUrls: ['./featured.component.css']
274274
})
275275
export class FeaturedComponent implements OnInit {
276276

277-
constructor(private location: Location) {
278-
}
277+
constructor(private location: Location) {
278+
}
279279

280-
ngOnInit(): void {
281-
}
280+
ngOnInit(): void {
281+
}
282282

283-
goBack(): void {
284-
this.location.back();
285-
}
283+
goBack(): void {
284+
this.location.back();
285+
}
286286
}
287287
```
288288
```featured.component.html
@@ -372,17 +372,17 @@ import { Component, OnInit } from "@angular/core";
372372
import { RouterExtensions } from "nativescript-angular/router";
373373

374374
@Component({
375-
selector: "Featured",
376-
templateUrl: "./featured.component.html",
377-
styleUrls: ['./featured.component.css']
375+
selector: "Featured",
376+
templateUrl: "./featured.component.html",
377+
styleUrls: ['./featured.component.css']
378378
})
379379
export class FeaturedComponent implements OnInit {
380380

381-
constructor(private routerExtensions: RouterExtensions) {
382-
}
381+
constructor(private routerExtensions: RouterExtensions) {
382+
}
383383

384-
ngOnInit(): void {
385-
}
384+
ngOnInit(): void {
385+
}
386386
}
387387
```
388388
```featured.component.html
@@ -398,17 +398,17 @@ export class FeaturedComponent implements OnInit {
398398
import { Component, OnInit } from "@angular/core";
399399

400400
@Component({
401-
selector: "Item",
402-
templateUrl: "./item.component.html",
403-
styleUrls: ['./item.component.css']
401+
selector: "Item",
402+
templateUrl: "./item.component.html",
403+
styleUrls: ['./item.component.css']
404404
})
405405
export class ItemComponent implements OnInit {
406406

407-
constructor() {
408-
}
407+
constructor() {
408+
}
409409

410-
ngOnInit(): void {
411-
}
410+
ngOnInit(): void {
411+
}
412412
}
413413
```
414414
```item.component.html
@@ -434,21 +434,21 @@ import { Component, OnInit } from "@angular/core";
434434
import { RouterExtensions } from "nativescript-angular/router";
435435

436436
@Component({
437-
selector: "Item",
438-
templateUrl: "./item.component.html",
439-
styleUrls: ['./item.component.css']
437+
selector: "Item",
438+
templateUrl: "./item.component.html",
439+
styleUrls: ['./item.component.css']
440440
})
441441
export class ItemComponent implements OnInit {
442442

443-
constructor(private routerExtensions: RouterExtensions) {
444-
}
443+
constructor(private routerExtensions: RouterExtensions) {
444+
}
445445

446-
ngOnInit(): void {
447-
}
446+
ngOnInit(): void {
447+
}
448448

449-
goBack(): void {
450-
this.routerExtensions.back();
451-
}
449+
goBack(): void {
450+
this.routerExtensions.back();
451+
}
452452
}
453453
```
454454
```item.component.html
@@ -561,11 +561,11 @@ import { Component, OnInit } from "@angular/core";
561561
})
562562
export class HubComponent implements OnInit {
563563

564-
constructor() {
565-
}
564+
constructor() {
565+
}
566566

567-
ngOnInit(): void {
568-
}
567+
ngOnInit(): void {
568+
}
569569
}
570570
```
571571
```hub.component.html
@@ -620,7 +620,7 @@ The `TabView` component enables the user to arbitrarily navigate between several
620620

621621
![navigation-diagram-ng-tab](../img/navigation/navigation-diagram-ng-tab.png?raw=true)
622622

623-
The `BottomNavigation` container provides its lateral navigation logic automatically by providing the user with tabs which they can select. To set up a `BottomNavigation` you need to simply declare the UI of each container via a `TabItemContent` and set the title and icon via coresponding `tabStripItem` (details on the basic structure [here](http://localhost:9192/angular/ui/ng-ui-widgets/bottom-navigation#usage)). Each separate UI container is represented by the `TabContentItem` component. As with other containers, you can enable forward and backward navigation inside each of them by embedding a `page-router-outlet` in it. In this case we need to use three sibling outlets. The way to do this with the Angular router is to use [named outlets](https://angular.io/guide/router#displaying-multiple-routes-in-named-outlets). Each of our outlets will be named with the name of the feature that it represents.
623+
The `BottomNavigation` container provides its lateral navigation logic automatically by providing the user with tabs which they can select. To set up a `BottomNavigation` you need to simply declare the UI of each container via a `TabItemContent` and set the title and icon via corresponding `tabStripItem` (details on the basic structure [here](http://localhost:9192/angular/ui/ng-ui-widgets/bottom-navigation#usage)). Each separate UI container is represented by the `TabContentItem` component. As with other containers, you can enable forward and backward navigation inside each of them by embedding a `page-router-outlet` in it. In this case we need to use three sibling outlets. The way to do this with the Angular router is to use [named outlets](https://angular.io/guide/router#displaying-multiple-routes-in-named-outlets). Each of our outlets will be named with the name of the feature that it represents.
624624

625625
The `BottomNavigation` widget also provides two important features connected to lateral navigation:
626626

@@ -712,7 +712,7 @@ export class AppComponent {
712712
```app.component.html
713713
<BottomNavigation selectedIndex="1">
714714
715-
<!-- The bottom tab UI is created via TabStrip (the containier) and TabStripItem (for each tab)-->
715+
<!-- The bottom tab UI is created via TabStrip (the container) and TabStripItem (for each tab)-->
716716
<TabStrip>
717717
<TabStripItem>
718718
<Label text="Home"></Label>
@@ -747,17 +747,17 @@ export class AppComponent {
747747
import { Component, OnInit } from "@angular/core";
748748

749749
@Component({
750-
selector: "Featured",
751-
templateUrl: "./featured.component.html",
752-
styleUrls: ['./featured.component.css']
750+
selector: "Featured",
751+
templateUrl: "./featured.component.html",
752+
styleUrls: ['./featured.component.css']
753753
})
754754
export class FeaturedComponent implements OnInit {
755755

756-
constructor() {
757-
}
756+
constructor() {
757+
}
758758

759-
ngOnInit(): void {
760-
}
759+
ngOnInit(): void {
760+
}
761761
}
762762
```
763763
```featured.component.html

docs/core-concepts/data-binding.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,22 @@ Another common case in working with bindings is requesting access to the parent
240240
_Example 4: Creating ListView child items based on the itemTemplate._
241241
``` XML
242242
<Page navigatingTo="onNavigatingTo" xmlns="http://schemas.nativescript.org/tns.xsd">
243-
<GridLayout rows="*" >{%raw%}
244-
<ListView items="{{ items }}">
245-
<!--Describing how the element will look like-->
246-
<ListView.itemTemplate>
247-
<GridLayout columns="auto, *">
248-
<Label text="{{ $value }}" col="0"/>
249-
<!--The TextField has a different bindingCotnext from the ListView, but has to use its properties. Thus the parents['ListView'] has to be used.-->
250-
<!-- Parent binding to a string property -->
243+
<GridLayout rows="*" >{%raw%}
244+
<ListView items="{{ items }}">
245+
<!--Describing how the element will look like-->
246+
<ListView.itemTemplate>
247+
<GridLayout columns="auto, *">
248+
<Label text="{{ $value }}" col="0"/>
249+
<!--The TextField has a different bindingCotnext from the ListView, but has to use its properties. Thus the parents['ListView'] has to be used.-->
250+
<!-- Parent binding to a string property -->
251251
<TextField text="{{ $parents['ListView'].test, $parents['ListView'].test }}" col="1"/>
252252

253253
<!-- Parent binding to a method onTap -->
254254
<Button text="Tap me" tap="{{ $parents['ListView'].onTap, $parents['ListView'].onTap }}" />
255-
</GridLayout>
256-
</ListView.itemTemplate>
257-
</ListView>
258-
{%endraw%}</GridLayout>
255+
</GridLayout>
256+
</ListView.itemTemplate>
257+
</ListView>
258+
{%endraw%}</GridLayout>
259259
</Page>
260260
```
261261
``` JavaScript
@@ -301,9 +301,9 @@ You can create a custom expression for bindings. Custom expressions could help i
301301

302302
``` XML
303303
<Page xmlns="http://schemas.nativescript.org/tns.xsd">
304-
<StackLayout>{%raw%}
305-
<TextField text="{{ sourceProperty, sourceProperty + ' some static text' }}" />
306-
{%endraw%} </StackLayout>
304+
<StackLayout>{%raw%}
305+
<TextField text="{{ sourceProperty, sourceProperty + ' some static text' }}" />
306+
{%endraw%}</StackLayout>
307307
</Page>
308308
```
309309

docs/core-concepts/error-handling.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,28 @@ This API also introduces a technique, which allows the developers to define cust
4343

4444
Example:
4545

46-
```
46+
```javascript
4747
import "./bundle-config";
4848
import * as application from "tns-core-modules/application";
49-
import * as traceModule from "tns-core-modules/trace"
49+
import * as traceModule from "tns-core-modules/trace";
50+
5051
const errorHandler: traceModule.ErrorHandler = {
51-
handlerError(err){
52-
//option 1 (development) - throw the error
52+
handlerError(err) {
53+
// Option 1 (development) - throw the error
5354
throw err;
5455

55-
//option 2 (development) - logging the error via write method provided from trace module
56+
// Option 2 (development) - logging the error via write method provided from trace module
5657
traceModule.write(err, "unhandled-error", type.error);
5758

58-
//(production) - custom functionality for error handling
59-
//reportToAnalytics(err)
59+
// (production) - custom functionality for error handling
60+
// reportToAnalytics(err)
6061
}
6162
}
6263

6364
traceModule.setErrorHandler(errorHandler)
6465
application.run({ moduleName: 'app-root' });
6566
```
67+
6668
The example shows how to define a custom handler and three possible options for handling the error via [trace]({%slug trace%}) module or while using custom functionality.
6769

6870
Further info about the error handing in NativeScript can be found [here](https://github.com/NativeScript/NativeScript/blob/master/HandlingErrors.md).

docs/core-concepts/memory-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Unlike iOS, both the Java and JavaScript in the Android runtime are managed. The
141141
Memory leaks are rare. If there is a pool of unreachable splices from either Java or JavaScript, at some point the V8 GC will notify the JavaScript instances that they are marked for collection, then the reference to the Java counterpart will be made weak. Then the next Android VM GC will collect the Java instances and the V8 GC after that will collect the JavaScript instances (because the Java counterparts will be dead).
142142

143143
#### Half-Dead Splice
144-
Since collection is driven by the garbage collectors it is possible to hold a weak reference to the JavaScript instance of a splice. After a V8 GC, the splice can make the reference to the Java instance weak allowing the Android VM GC to collect it. Then, if before the next V8 GC the JavaScript instance is obtained from the weak reference and its methods are called, it will result in accessinga a half-dead splice (since the Java counterpart is dead already). The error reported by the runtime points out that we've failed to find an object for a given id. These problems are perceived as random and are quite hard to reproduce.
144+
Since collection is driven by the garbage collectors it is possible to hold a weak reference to the JavaScript instance of a splice. After a V8 GC, the splice can make the reference to the Java instance weak allowing the Android VM GC to collect it. Then, if before the next V8 GC the JavaScript instance is obtained from the weak reference and its methods are called, it will result in accessing a half-dead splice (since the Java counterpart is dead already). The error reported by the runtime points out that we've failed to find an object for a given id. These problems are perceived as random and are quite hard to reproduce.
145145

146146
#### Splices Die Fast
147147
Multiple splices and JavaScript instances can be created for a single Java object, properties may be lost.

docs/core-concepts/plugins.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ As shown above the command **tns plugin add <plugin-name>** is actually doing **
5353
npm i tns-platform-declarations --save-dev
5454
```
5555

56-
> **Note:** The difference between dependencies and developer dependencies is that **dependencies** are required to run, while **devDependencies** are needed only during development. Example for dependency is the **nativescript-camera** plugin which is required runtime so you could use the hardware camera. On the other hand, the **tns-platform-declarations** is a developer dependency required only for intelliSense during the development process. The `devDependncies` should not be installed as `dependencies` to avoid large output build files (large application size). Example `package.json` file using both `dependencies` and `devDependencies` can be found [here](https://github.com/NativeScript/nativescript-sdk-examples-js/blob/master/package.json#L31-L44).
56+
> **Note:** The difference between dependencies and developer dependencies is that **dependencies** are required to run, while **devDependencies** are needed only during development. Example for dependency is the **nativescript-camera** plugin which is required runtime so you could use the hardware camera. On the other hand, the **tns-platform-declarations** is a developer dependency required only for intelliSense during the development process. The `devDependencies` should not be installed as `dependencies` to avoid large output build files (large application size). Example `package.json` file using both `dependencies` and `devDependencies` can be found [here](https://github.com/NativeScript/nativescript-sdk-examples-js/blob/master/package.json#L31-L44).
5757
5858
## Importing and Using Plugins
5959

docs/core-concepts/properties.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,16 @@ marginBottomProperty.register(Style);
131131
The `CoercibleProperty` is a property that extends the base Property class by providing the capability to be coercible. For better illustration when a property might need to be coercible let's assume that we are working on `selectedIndex` property of some UI element that can hold different number of `items`. The base case would suggest that the `selectedIndex` would vary within the number of items, but what would cover the case where the items are changed dynamically (and the `selectedIndex` is not within the length range)? This is the case that can be handled by a property that can coerce the value.
132132

133133

134-
Creating the `selectedIndex` as coercible property dependend on the number of items
134+
Creating the `selectedIndex` as coercible property dependent on the number of items
135135
```TypeScript
136136
export const selectedIndexProperty = new CoercibleProperty<SegmentedBarBase, number>({
137137
name: "selectedIndex", defaultValue: -1,
138138
valueChanged: (target, oldValue, newValue) => {
139139
target.notify(<SelectedIndexChangedEventData>{ eventName: SegmentedBarBase.selectedIndexChangedEvent, object: target, oldIndex: oldValue, newIndex: newValue });
140140
},
141141

142-
// in this case the coerse value will change depending on whether the actual number of items
143-
// is more or less than the value we want to appl for selectedIndex
142+
// in this case the coerce value will change depending on whether the actual number of items
143+
// is more or less than the value we want to apply for selectedIndex
144144
coerceValue: (target, value) => {
145145
let items = target.items;
146146
if (items) {
@@ -280,7 +280,7 @@ Each UI element extends the `View` class (e.g., like `StackLayout` or `Label`) a
280280
> As an alternative, in Angular, we can get reference to the native elements using the `ViewChild` directive and the `nativeElement` property.
281281
> ```HTML
282282
> <StackLayout #myNgStack id="myStackId">
283-
> <Label text="Using ViewChild agains getViewById" />
283+
> <Label text="Using ViewChild against getViewById" />
284284
> </StackLayout>
285285
> ```
286286
> ```TypeScript

0 commit comments

Comments
 (0)