Building Mobile Apps with Web technologies
Daniel Popescu
Native Apps
vs
Hybrid Apps
Hybrid Apps
Options
Cordova
Ionic 2
Angular 2
TypeScript
Webpack
Angular 2
TypeScript / ES6
Classes
class Base {
private a: number;
constructor(value: number){
this.a = value;
}
public get a():number {
return this.a;
}
}
class A extends Base {
constructor(value: number){
super(value);
}
public get a():number{
return super.a * 2;
}
}
let base: Base = new Base(2);
console.log(base.a); // '2'
let extendedBase: Base = new A(2);
console.log(extendedBase.a); // '4'
String interpolation
let firstName: string = "John";
let lastName: string = "Doe";
let hello: string = `Hello, ${firstName} ${lastName}`;
console.log(hello); // Hello, John Doe
Arrow functions
class Test {
private test: string = "I'm private";
public getPrivateString(){
return () => {
return this.test;
}
}
}
let test: Test = new Test();
console.log(test.getPrivateString()); // I'm private
Interfaces
interface Contact {
firstName: string;
lastName: string;
}
class Person implements Contact {
public firstName: string;
public lastName: string;
constructor(firstName: string, lastName: string){
this.firstName = firstName;
this.lastName = lastName;
}
}
let people: Contact[] = [new Person("a", "b"), new Person("c", "d")];
Coding
Building Mobile Apps with Web technologies
By Daniel Popescu
Building Mobile Apps with Web technologies
- 6