Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7966be5
Starting version for print magazine (very formal German language)
JohannesHoppe Apr 24, 2016
c11d3cb
Was ist NativeScript?
JohannesHoppe Apr 24, 2016
7a3be56
Xcode is an IDE -> Objective-C / Swift
JohannesHoppe Apr 24, 2016
c501d3c
switching to the magazine's template for now (less conversions in the…
JohannesHoppe Apr 24, 2016
241a957
finishing: Warum NativeScript? (why NativeScript)
JohannesHoppe Apr 24, 2016
cbce25c
+ Open Source
JohannesHoppe Apr 24, 2016
69288d9
+ Abstraktionsschicht (Abstraction Layer)
JohannesHoppe Apr 24, 2016
918ea82
...
JohannesHoppe Apr 24, 2016
8321a53
+ Platformspezifischer Code (Platform specific code)
JohannesHoppe Apr 24, 2016
0f3878b
+ Styling (CSS)
JohannesHoppe Apr 25, 2016
4b1a71c
corrections
JohannesHoppe Apr 25, 2016
329884a
mentioning JavaScript-VMs and Reflection
JohannesHoppe Apr 25, 2016
42abd4c
in angular-world you can call that guy a "class" or "service", but th…
JohannesHoppe Apr 25, 2016
829e9ac
+ angular 2
JohannesHoppe Apr 26, 2016
72f45c8
changing abstraction layer image
JohannesHoppe Apr 26, 2016
2e8887d
changing "Login" to "SignUp", since the screenshot shows something di…
JohannesHoppe Apr 26, 2016
6205e62
+ fazit
JohannesHoppe Apr 26, 2016
d91e9af
.gitignore tmp word files
JohannesHoppe Apr 26, 2016
863699b
a lot of corrections
JohannesHoppe Apr 26, 2016
86736b2
corrections
JohannesHoppe Apr 27, 2016
b0c405e
even more corrections
JohannesHoppe Apr 27, 2016
496c84a
reverting rename-changes on the NG2 code example
JohannesHoppe Apr 27, 2016
7ceb58c
Telerik +- Progress Software
JohannesHoppe Apr 28, 2016
453158f
cleanup
JohannesHoppe Apr 28, 2016
f7e50fe
cleanup
JohannesHoppe Apr 28, 2016
bd94022
cleanup
JohannesHoppe Apr 28, 2016
b552719
cleanup
JohannesHoppe Apr 28, 2016
76eec86
Merge remote-tracking branch 'sebastian/master'
JohannesHoppe Jun 14, 2016
f7dec2b
link to https://medium.com/@urish/building-simon-with-angular2-iot-fc…
JohannesHoppe Jun 14, 2016
5b570a3
translated first part
JohannesHoppe Jun 14, 2016
ba80568
text: Abstraction Layer
JohannesHoppe Jun 14, 2016
1878db0
text: direct access
JohannesHoppe Jun 14, 2016
fd45c75
finishing text
JohannesHoppe Jun 14, 2016
8c7e2c2
+ link
JohannesHoppe Jun 14, 2016
6a21d25
small typos
JohannesHoppe Jun 15, 2016
007354d
erste version für die dotnetpro
JohannesHoppe Jun 27, 2016
05d8fb1
absätze
JohannesHoppe Jun 27, 2016
9ad587f
dotnetpro: mehr details zu angular 2
JohannesHoppe Jun 27, 2016
434bc17
dotnetpro: bootstrapping
JohannesHoppe Jun 27, 2016
3ecc84a
+ editors
JohannesHoppe Jun 28, 2016
4451081
tinypng.com & tinyjpg.com + new german blue pictures
JohannesHoppe Jun 28, 2016
5cba326
linking blue images
JohannesHoppe Jun 28, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
~*
1 change: 0 additions & 1 deletion Angular-for-all

This file was deleted.

34 changes: 27 additions & 7 deletions Angular2-for-all-platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ Angular is the most popular framework for building client side web applications
Over the last few years it enabled over 1 million developers to build great Single Page Web Applications.
However the framework was always limited to the web only, which meant that you would have to use totally different tools/languages/frameworks if you needed to target desktop and mobile applications as well.


## Platform agnostic architecture

This is where Angular 2 comes into play. The new version is completely platform agnostic, which means that it is designed to be used with various different platforms (be it web, mobile or desktop).
This is where Angular 2 comes into play. The new version is completely platform agnostic, which means that it is designed to be used with various different platforms (be it web, mobile, desktop or even all kind of [IoT devices](https://medium.com/@urish/building-simon-with-angular2-iot-fceb78bb18e5)).
In simple terms the architecture is split into two parts:
- Platform agnostic - where your markup (HTML) is parsed by a Dom Adapter and then compiled into a set of Proto Views. This process is not specific to any platforms and most of its pieces can be shared between platforms.
- Platform specific - here is where the magic happens. To target each platform you need a Platform Specific Renderer, which based on the Proto Views generates a Visual Tree (used to display the UI). The Renderer is also responsible for propagating the changes and events between the Proto Views and the Visual Tree.
Expand All @@ -15,7 +16,12 @@ In simple terms the architecture is split into two parts:

With this architecture in place it was a matter of creating the necessary extensions to target different platforms.


## Adding mobile to the picture


![Login Screen](./images/LoginScreen.png "Login Screen")

This opened up the doors to [NativeScript](https://www.nativescript.org/), an Open Source framework for building iOS, Android and ([soon](https://www.nativescript.org/blog/details/nativescript-runtime-preview-for-windows-10)) Windows Universal apps with 100% Native UI.
Since the middle of 2015 both the Angular and the NativeScript teams have been working on bringing the two together. This resulted in the creation of NativeScript 2.0 ([news](http://sdtimes.com/nativescript-2-0-brings-mobile-strategy-options-angularjs-developers/)).

Expand All @@ -24,8 +30,11 @@ As a result NativeScript uses HTML as the markup to define the UI structure and
Here is how this fits in the Angular 2 architecture.
![Angular2 with NativeScript](./images/Angular2-with-NativeScript.png "Angular2 with NativeScript")


## Why NativeScript

![Login Screen](./images/nativescript-loves-angular.png)

### It works with Angular 2
You can use all of the [Angular 2 syntax](https://angular.io/docs/ts/latest/guide/template-syntax.html#) and get a mobile app as a result:
```HTML
Expand Down Expand Up @@ -93,20 +102,31 @@ Obviously no abstraction layer can cover all the possible functions available on
For example if you run the below ***JavaScript*** code on Android, you will get a new instance of a file object.

```JavaScript
function openFile(url) {
function openFile() {
var myFile = new java.io.File("filePath.txt");
return myFile;
}
```

## Single codebase for all
> Should I include this part??? or would this be too much???

## Want to learn more?

[![Banner DWX](images/developer-week.jpg)](http://www.developer-week.de/)

There will be a couple of talks about NativeScript at DWX, which are really worth attending.
* [Introduction to NativeScript](http://www.developer-week.de/Programm/Veranstaltung/(event)/20557) on Monday 20-June at 17:00 - in this talk you will learn what NativeScript is made of, how it works inside and you will see some JavaScript examples on how to build mobile apps with it.
* [Native Mobile Apps mit NativeScript und Angular 2.0](http://www.developer-week.de/Programm/Veranstaltung/(event)/20683) on Wednesday 22-June at 9:00 - in this talk you will learn how we built the NativeScript 2.0, how does it work with Angular 2 and how to aim for a shared code base between mobile and web apps.
* [Introduction to NativeScript][1] on Monday 20-June at 17:00 - in this talk you will learn what NativeScript is made of, how it works inside and you will see some JavaScript examples on how to build mobile apps with it.
* [Native Mobile Apps mit NativeScript und Angular 2.0][2] on Wednesday 22-June at 9:00 - in this talk you will learn how we built the NativeScript 2.0, how does it work with Angular 2 and how to aim for a shared code base between mobile and web apps.

There is a great [Getting Started guide](http://docs.nativescript.org/angular/tutorial/ng-chapter-0), which you can follow to build a Native iOS and Android mobile app with Angular2 and NativeScript.

![Login Screen](./images/LoginScreen.png "Login Screen")

[1]: http://www.developer-week.de/Programm/Veranstaltung/(event)/20557
[2]: http://www.developer-week.de/Programm/Veranstaltung/(event)/20683

---

[![Sebastian](images/Sebastian_Witalec_small.png)](https://twitter.com/sebawita)
[Sebastian Witalec](https://twitter.com/sebawita), Technical Evangelist for Telerik, a Progress company

[![Joannes](images/Johannes_Hoppe_small.png)](https://twitter.com/johanneshoppe)
[Johannes Hoppe](https://twitter.com/johanneshoppe), Telerik Developer Expert
136 changes: 136 additions & 0 deletions Angular2-fuer-alle-Plattformen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Mobile Apps mit Angular 2 entwickeln

In den letzten Jahre haben mehr als eine Million Entwickler erfolgreich mit AngularJS Single-Page-Anwendungen erstellt. Angular ist damit das populärste Framework um client-seitige Webanwendungen zu entwickeln (siehe z.B. [Stack Overflow](http://stackoverflow.com/research/developer-survey-2016#most-popular-technologies-per-occupation)). Allerdings blieb das Framework dabei bislang immer auf das Web beschränkt. Das bedeutet, dass man bis dato völlig andere Tools, Programmiersprachen und Frameworks benötigte, um Anwendungen für den Desktop oder für mobile Geräte an den Start zu bringen.


## Plattformunabhängige Architektur

Hier wird Angular 2 interessant. Der komplette Rewrite von AngularJS 1 wurde stark auf Plattformunabhängigkeit ausgerichtet. Das bedeutet, dass das Framework so entworfen wurde, dass diverse Plattformen angesprochen werden können (sei es Web, Mobil, Desktop und sogar [IoT-Geräte](https://medium.com/@urish/building-simon-with-angular2-iot-fceb78bb18e5)).
Vereinfacht ausgedrückt ist die Angular-2-Architektur in zwei Teile aufgeteilt:

- __Plattform-unabhängiger Teil__: hier wir das Markup (HTML) durch einen DOM-Adapter geparst und in so genannte „Proto Views“ compiliert. Dieser Prozess ist nicht spezifisch für eine Zielplattform und die meisten Funktionen können in den verschiedenen Plattformen genutzt werden
- __Plattform-spezifischer Teil__: hier geschieht die Magie. Es werden plattformspezifische Renderer verwendet, um die unterschiedlichen Zielplattformen abzubilden. Jene Renderer haben die Aufgabe, aus den „Proto Views“ einen „Visual Tree“ zu generieren. Dieser kann dann verwendet werden, um die Oberfläche anzuzeigen. Der Renderer ist ebenso dafür verantwortlich, Änderungen und Events zwischen „Proto Views“ und „Visual Tree“ auszutauschen.


![Angular2 Platform Agnostic](./images/Angular2-platform-agnostic.png "Angular2 Platform Agnostic")

Durch diese durchdachte Architektur ist es möglich, neue Ziele zu definieren. Es müssen nur die notwendigen Erweiterungen implementiert werden.


## Native Mobile Anwendungen

![Login Screen](./images/LoginScreen.png "Login Screen")

Auf Grundlage der plattformunabhängigen Architektur von Angular kann [NativeScript](https://www.nativescript.org/) seine Stärken zeigen. NativeScript ist ein Open-Source-Framework, mit dem man native Apps für iOS, Android und [bald](https://www.nativescript.org/blog/details/nativescript-runtime-preview-for-windows-10) auch Windows 10 bzw. Windows Phone 10 entwickeln kann. „Nativ“ bedeutet, dass tatsächlich echte native UI-Elemente aus der JavaScript-Umgebung heraus angesprochen werden können. Seit Mitte 2015 arbeiten das Angular-Team und das NativeScript-Team zusammen, um beide Frameworks miteinander zu verbinden. Das Ergebnis dieser Zusammenarbeit ist NativeScript 2.0 ([News](http://sdtimes.com/nativescript-2-0-brings-mobile-strategy-options-angularjs-developers/)).

Die Lösung für Angular 2 besteht darin, dass sehr spezielles Markup in HTML definiert wird. Diese Markup kann dann vom DOM-Adapter „Parse5“ geparst werden. Den größten Anteil an der Umsetzung nimmt der „NativeScript Renderer“ ein. Dieser garantiert nicht zuletzt den Austausch zwischen „Proto Views“ und den nativen UI Komponenten der jeweiligen Platform:

![Angular2 with NativeScript](./images/Angular2-with-NativeScript.png "Angular2 with NativeScript")


## Warum NativeScript?

![Login Screen](./images/nativescript-loves-angular.png)

### Kurzum: es funktioniert wunderbar mit Angular 2

Wenn man erstmal die neue [Template-Syntax](https://angular.io/docs/ts/latest/guide/template-syntax.html) von Angular gelernt hat, dann kann man das bestehende Wissen auf eine NativeScript-App übertragen. Hier ist ein einfaches Beispiel, wie ein Button verarbeitet wird. Es fällt auf, dass dies Komponente kein normales HTML beinhaltet:

```HTML
@Component({
selector: "my-app",
template: `
<Page>
<StackLayout>
<Button text="Tap Me" (tap)="onTap()"></Button>
<Label [text]="counter"></Label>
<Label *ngIf="counter>10" text="WOW!!! you are really good"></Label>
</StackLayout>
</Page>
`
})
export class MyComponent {
counter: number = 0;
onTap() {
this.counter++;
}
}
```

### Abstraktionsschicht

NativeScript hat eine beträchtliche Abstraktionsschicht an Board, welche die Unterschiede zwischen den unterstützen Zielplattformen (iOS, Android, UWP) ausbügelt. Hierdurch kann man mit einer einzigen Code-Basis alle nennenswerten Geräte bedienen. Besonders wichtig ist eine gescheite UI-Abstraktion, bei der jede [UI-Komponente](http://docs.nativescript.org/ui/ui-views) eine eigene native Implementierung besitzen muss. Zum Glück müssen wir nicht diese spezifische Implementierungen selbst entwickeln. Es wurde bereits eine grundlegende Auswahl an Bedienelementen vom NativeScript-Team umsetzt. So können wir folgendes Markup definieren und erhalten eine ***native Oberfläche***, die in allen Betriebsystemen die jeweils zu erwarteten Bedienelemente besitzt:

```HTML
@Component({
selector: "my-app",
template: `
<Page>
<StackLayout>
<Button text="GO" (tap)="onTap()" height="50" width="100"></Button>
<Label [text]="selectedIndex" height="50" width="100"></Label>
<ListPicker [selectedIndex]="selectedIndex" [items]="items"></ListPicker>
<DatePicker [day]="day" [month]="month" [year]="year"></DatePicker>
<TimePicker [hour]="hour" [minute]="minute"></TimePicker>
</StackLayout>
</Page>
`
})
```

Weiterhin bietet das NPM-Paket „**T**elerik **N**ative**S**cript Core Modules“ (kurz: [tns-core-modules](https://github.com/NativeScript/NativeScript/tree/master/tns-core-modules)) eine reiche Auswahl an Funktionalitäten, die man gemeinhin für die App-Entwicklung benötigt. Möchte man z.B. ein Foto mit der Kamera machen, so muss man lediglich das entsprechende [Kamera-Modul](https://docs.nativescript.org/hardware/camera#using-the-camera-module-to-take-a-picture) mit `require` laden und es aufrufen. Wie die Kamera in den jeweiligen Betriebssystemen aufgerufen werden muss, braucht uns dann nicht mehr zu interessieren.


```JavaScript
import {Image} from "ui/image";
import cameraModule = require("camera");

cameraModule.takePicture().then(picture => {
console.log("Result is an image source instance");
var image = new Image();
image.imageSource = picture;
});
```

Wenn Sie allerding neugierig sind, was unter Android ([Github](https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/camera/camera.android.ts#L9-L111)) oder iOS ([Github](https://github.com/NativeScript/NativeScript/blob/master/tns-core-modules/camera/camera.ios.ts#L82-L126)) passiert, wenn die Methode `takePicture` aufgerufen wird, dann schauen sich am einfach das [Github-Repository](https://github.com/NativeScript/NativeScript/tree/master/tns-core-modules) an. Dort sind alle Core-Komponenten gesammelt.


### Direkter Zugriff auf Native APIs

Natürlich kann keine Abstraktionsschicht alle möglichen Funktionen abdecken. Ebenso möchte man womöglich für bestimmte Aufgaben eine native Fremdbibliothek eines Drittanbieters einbinden. Unter NativeScript stellt dies kein Problem dar. Es ist nämlich stets möglich, direkt aus **JavaScript** heraus Android- oder iOS-APIs anzusprechen. Zum Beispiel wird folgender Quelltext unter Android (und nur unter Android) eine Instanz des Datei-Objekts erzeugen:

```JavaScript
function openFile() {
var myFile = new java.io.File("filePath.txt");
return myFile;
}
```

Das Beste an der gezeigten Syntax ist die Tatsache, dass sowohl Namespaces, als auch Attribute und Typen sowie die gesamten Konventionen bei der Benennung dem Pendant aus der Android- bzw. iOS-Dokumentation entspricht. Dasselbe gilt für Fremdbibliotheken. So lässt sich mit geringem Aufwand ein Code-Fragment aus den Dokumentationen oder dem Netz per Copy-and-Paste zum Laufen bringen. Hinter den Kulissen verwendet NativeScript „Reflection“, um eine Liste von APIs aufzubauen, die auf der aktuellen Plattform zur Verfügung stehen und zum globalen Gültigkeitsbereich hinzugefügt werden. Gibt es eine API auf dem Endgerät, dann kann man diese auch aufrufen!


## Lust auf mehr?

[![Banner DWX](images/developer-week.jpg)](http://www.developer-week.de/)

Auf der DWX-Developer Week 2016 wird es zwei Vorträge zu NativeScript geben.

* [Introduction to NativeScript][1], 20.06.2016 17:00 - 18:00 Uhr, Track: Cross-Plattform
In diesem Talk erfahren Sie, wie NativeScript aufgebaut ist, wie es funktioniert und vor allem wie man performante mobile Apps mit dem Framework entwickeln kann.
* [Native Mobile Apps mit NativeScript und Angular 2][2], 22.06.2016 09:00 - 10:00 Uhr, Track: Mobile Architekturen
In diesem schauen wir uns das Zusammenspiel zwischen NativeScript und Angular 2 genauer an. Als besonderes Schmankerl zeigen wir Ihnen, wie man auf Grundlage von Angular Code für mobile Apps und Webanwendungen wiederverwenden kann.


Sie sollten auch den ausführlichen [Getting Started guide](http://docs.nativescript.org/angular/tutorial/ng-chapter-0) durchlesen. Hier erfahren Sie alles Notwendige, um native Apps für iOS und Android auf Basis von Angular2 und NativeScript zu entwickeln.


[1]: http://www.developer-week.de/Programm/Veranstaltung/(event)/20557
[2]: http://www.developer-week.de/Programm/Veranstaltung/(event)/20683

---

[![Sebastian](images/Sebastian_Witalec_small.png)](https://twitter.com/sebawita)
[Sebastian Witalec](https://twitter.com/sebawita), Technical Evangelist for Telerik, a Progress company

[![Joannes](images/Johannes_Hoppe_small.png)](https://twitter.com/johanneshoppe)
[Johannes Hoppe](https://twitter.com/johanneshoppe), Telerik Developer Expert
30 changes: 10 additions & 20 deletions Introduction-to-Nativescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ However NativeScript belongs to the JavaScript Native category of building mobil
# Why NativeScript?

## Skills reuse
If you already know **JavaScript**, *(optionally)* **TypesScript** and **CSS**, then you already have a big chunk of skills required to build mobile apps. You don't need to learn **Xcode**, **Java** and **C#** to target multiple platforms.
If you already know **JavaScript**, *(optionally)* **TypesScript** and **CSS**, then you already have a big chunk of skills required to build mobile apps. You don't need to learn **Objective-C**, **Swift**, **Java** and/or **C#** to target multiple platforms.

Further more if you are coming from the Angular backgroud, you coud use NativeScript with **Angular 2.0**. We will come back to this point in a moment, as this is a real game changer.

Expand Down Expand Up @@ -45,9 +45,10 @@ You get the best of the two worlds, a great piece of technology supported by a s
# Abstraction Layer

NativeScript lets you target multiple platforms without you having to write a single line of a platform specific code.
This can be achieved thanks to **tns-core-modules** (available from npm) an **Abstraction Layer** that contains platform specific implementation for each supported platfrom. It provides with modules that cover many different aspects of a mobile app from **UI abstraction**, through **Device Sensors** to **Hardaware Access** and many more.
This can be achieved thanks to **tns-core-modules** (available from npm) an **Abstraction Layer** that contains platform specific implementation for each supported platfrom. It provides with modules that cover many different aspects of a mobile app from **UI abstraction**, through **Device Sensors** to **Hardware Access** and many more.

![Abstraction Layer](./images/Abstraction-Layer.png "Abstraction Layer")
<!--![Abstraction Layer](./images/Abstraction-Layer.png "Abstraction Layer")-->
![Abstraction Layer](./images/Abstraction-Layer_v2.png "Abstraction Layer")

Thanks to the **tns core modules** you no longer need to think on how to perform the same operation using 3 different Platform APIs, but instead you can concentrate on the what and not how.

Expand Down Expand Up @@ -130,7 +131,7 @@ This means that now you have another way of using NativeScript. You can build yo

For example if you want to add a login screen to your app you could do it in the following steps:

### 1) Create a UserService Component, which will contain the code to login.
### 1) Create a UserService class, which will contain the code to login.

```JavaScript
import {Injectable} from "angular2/core";
Expand Down Expand Up @@ -182,32 +183,21 @@ export class LoginPage {
```HTML
<StackLayout>
<Image src="res://logo_login" stretch="none" horizontalAlignment="center"></Image>
<TextField hint="Email Address" [(ngModel)]="username"></TextField>
<TextField hint="Email" [(ngModel)]="username"></TextField>
<TextField hint="Password" secure="true" [(ngModel)]="password"></TextField>
<Button [text]="Sign in" (tap)="login()"></Button>
<Button [text]="Sign up" (tap)="login()"></Button>
<Button [text]="Back to login"></Button>
</StackLayout>
```

With a bit of extra styling the Login Screen should look something like this:
![Login Screen](./images/LoginScreen.png "Login Screen")





> Reword this somehow
# Reword this somehow
Angular 2 provides the architecture and mechanisms for the application logic to communicate with the UI components, while NativeScript provides the mechanism to interact with the Native APIs and Native UI components.
>You get the best of the two worlds: NativeScript's access to the Native UI and API and Angular's mechanisms.


# How does this change your mobile strategy
You get the best of the two worlds: NativeScript's access to the Native UI and API and Angular's mechanisms.

## The bigger picture > Mobile/Web/Desktop
![Multi-Platform](./images/AngularMultiPlatform.png "Multi-Platform")

## Dev team setup
![Team Setup](./images/TeamSetup.png "Team Setup")

# Other
## Getting started pointers -> http://docs.nativescript.org/getting-started
## Performance – Native UI ???
Binary file not shown.
Loading