...and disecting Tour of Heroes
Presented by Tom Friedhof
http://youtube.com/activelamp
TypeScript is a typed superset of Javascript that compiles to plain Javascript.
Find out about errors at compile time
function greeter(person) {
return "Hello, " + person;
}
var user = "Jane User";
document.body.innerHTML = greeter(user);
function greeter(person: string) {
return "Hello, " + person;
}
var user = {
"id": 1,
"name": "Jane User",
};
document.body.innerHTML = greeter(user);
interface Person {
id: number;
name: string;
}
function greeter(person: Person) {
return "Hello, " + person.name;
}
var user = {
"id": 1,
"name": "Jane User",
};
document.body.innerHTML = greeter(user);
interface Person {
id: number;
name: string;
greeter(name: string): void;
}
class Man implements Person {
constructor(public id, public name) {
this.id = id;
this.name = name;
}
greeter() {
return "Hello, " + this.name;
}
}
var user = new Man(1, 'Jake Speed');
document.body.innerHTML = user.greeter();
A component is the combination of an HTML template and a component class that controls a portion of the screen.
import { Component } from '@angular/core';
@Component({
selector: 'my-app',
template: `Hello {{name}}
`
})
export class AppComponent {
name = 'Angular';
}
Install the CLI tool
npm install -g angular-cli
Create the project
ng new my-app
Serve the app
cd my-app
ng serve
(Angular CLI)
Send me an email:
tom@activelamp.com