Chris Sevilleja
Making scotch.io. Google Dev Expert. Champion pizza maker.
Handle multiple events
Cancellable
Operators to manipulate data (map(), filter())
Operators to retry (retry(), replay())
getUsers() {
return this.http.get('http://blambloom.com/api/comments');
}
this.getUsers()
.subscribe(users => console.log(users));
Login to an API
Get a JSON Web Token (JWT)
Learned about Observables
Used the HTTP library
CRUD: GET, POST, PUT, DELETE
Communicated between components
Only authenticated users can access
Ability to edit users
Environment Setup
Angular CLI
npm install -g angular-cli
ng new my-app
ng start
|- app/
|----- app.component.ts
|----- app.module.ts
|----- app.main.ts
|- index.html
|- package.json
|- tsconfig.json
|- typings.json
|- systemjs.config.js
|- app/
|----- app.component.ts
|----- app.module.ts
|----- app.main.ts
|- index.html
|- package.json
|- tsconfig.json
|- typings.json
|- systemjs.config.js
[ ] = property bindings
( ) = event bindings
The Banana in a Box
[(ngModel)]
The Banana in a Box
[(ngModel)]
@Input()
@Input()
@Output() and EventEmitter
{
name: 'Basketball',
slug: 'basketball',
description: 'Throwing balls into baskets.'
}
// message has to be a string
function saySomething(message: string) {
...
}
// throws an error !!!!!
saySomething(500);
// no error
saySomething('whats up');
// typescript class ========================
class Greeter {
greeting: string;
greet() {
return "Hello, " + this.greeting;
}
}
// compiled to javascript ==================
var Greeter = (function () {
function Greeter() {
}
Greeter.prototype.greet = function () {
return "Hello, " + this.greeting;
};
return Greeter;
}());
// typescript ===============================
function saySomething(message: string) {
console.log(message);
}
let message = 'angular is the bees knees';
saySomething(message);
// compiled javascript ======================
function saySomething(message) {
console.log(message);
}
var message = 'angular is the bees knees';
saySomething(message);
@Component({ <-- decorator!
selector: 'my-app',
template: '<h1>Hello!</h1>'
})
export class AppComponent {}
// typescript class ========================
class Greeter {
greeting: string;
greet() {
return "Hello, " + this.greeting;
}
}
// compiled to javascript ==================
var Greeter = (function () {
function Greeter() {
}
Greeter.prototype.greet = function () {
return "Hello, " + this.greeting;
};
return Greeter;
}());
Local
mongodb://<user>:<pass>@localhost/olympics
Remote
mongodb://<user>:<pass>@ds1343.mlab.com:43234/olympics
For a quick remote database
Keeping secrets a secret
Convenient data handling in Node
Sample data to work with
See what's in the database
users
posts
Create sample data quickly.
Fill our database with sample data.
Top down overview.
CSS and JS for our application.
Simple and extendable views.
Only admins can access.
Only admins can see.
By Chris Sevilleja