What is an app and
how do I make one?
Coding for the Curious Crash Course
Andy Carnahan andrew@craftacademy.se
@CraftAcademySE #CuriousCoder #CrashCourse
First, fill out this form:
https://ca-address-book.herokuapp.com/
Your information will be shared with everyone
in this room, but we’ll delete all your info in a
couple days so nobody else gets it.
@CraftAcademySE #CuriousCoder #CrashCourse
Apps vs. Websites:
It’s complicated
A short summary: if you can log in, it’s an app. If
you see the same information as every other
visitor, it… may not be an app.
@CraftAcademySE #CuriousCoder #CrashCourse
Apps you’ve seen:
Static sites. No forms. Primarily for showing
information, not accepting it.
Websites
What about phones?
APIs: sending and receiving information
between computer systems
Application
Programming
Interface
@CraftAcademySE #CuriousCoder #CrashCourse
{
contacts:
[
{
name: "Thomas Ochman",
email: "thomas@craftacademy.se",
company: "CraftAcademy",
role: "Managers",
twitter: "thomasochman",
location: "Gothenburg",
info: "Nothing...",
image: "https://ca-address-book.herokuapp.com/images/desert.jpg"
},
{
name: "Raoul",
email: "diraulo@craftacademy.se",
company: "Craft Academy",
role: "Chief computer wizard ;-)",
twitter: "diraulo",
location: "Pretoria",
info: "Yeah well, you know... All round badass ",
image: "https://ca-address-book.herokuapp.com/images/ocean.jpg"
}
]
}
Our API
https://ca-address-book.herokuapp.com/api/contacts
@CraftAcademySE #CuriousCoder #CrashCourse
Consuming our API
with Angular!
● Do you have Node? In your
terminal, type:
$ node -v
● Now try:
$ npm -v
● If those two commands gave
you numbers, great! If not:
https://nodejs.org/en/download/
@CraftAcademySE #CuriousCoder #CrashCourse
We need a text
editor, too
www.atom.io
@CraftAcademySE #CuriousCoder #CrashCourse
Run these commands in your terminal:
$ npm install -g @angular/cli
When that finishes (you’ll get a prompt back with a $):
$ ng new address-book
When that one finishes (it will take a while):
$ cd address-book
Now open up Atom, navigate to the address-book folder and you
should see a bunch of files. We’re almost ready to get coding!
@CraftAcademySE #CuriousCoder #CrashCourse
IGNORE:Everything that is not in the /src/app folder
@CraftAcademySE #CuriousCoder #CrashCourse
DELETE:/src/app/app.component.spec.ts
@CraftAcademySE #CuriousCoder #CrashCourse
Fire up your server!
Type in your
terminal:
ng serve
Visit in your
browser:
localhost:4200
@CraftAcademySE #CuriousCoder #CrashCourse
Get in the steering wheel.
Open up /src/app/app.component.ts
On line 9, you’ll see
title = ‘app’
Look familiar?
Change the text in quotes to anything
your heart desires for instance “all
workshop participants“
Now go back to your browser - you have
just written code.
@CraftAcademySE #CuriousCoder #CrashCourse
Now, we’ll write some HTML.
<ng-container class="container">
<div class="card">
<div class="image">
<img src="#"/>
</div>
<div class="content">
<div class="location">Gothenburg</div>
<h1>Nils Magnusson</h1>
<h2>CEO, NM.com</h2>
<p>Nils is a great made-up guy.</p>
nils@nils.com |
<a href="http://www.twitter.com/nilsmagnusson">@nilsmagnusson</a>
</div>
</div>
</ng-container>
Put this into /src/app/app.component.html
import { Component } from '@angular/core';
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
data = {};
private apiUrl =
'https://ca-address-book.herokuapp.com/api/contacts';
constructor(private http: Http) {
this.getContacts().subscribe(data => {
console.log(data);
});
}
getContacts() {
return this.http.get(this.apiUrl)
.map((res: Response) => res.json());
}
}
Let’s do this. We need to edit
/app/app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app works!';
}
@CraftAcademySE #CuriousCoder #CrashCourse
If you just installed @angular/cli you also need to
edit /app/app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
import { BrowserModule } from
'@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Let’s remove the placeholders and grab real info in
/src/app/app.component.html
<ng-container *ngFor="let contact of data.contacts" class="container">
<div class="card">
<div class="image">
<img src="{{contact.image}}"/>
</div>
<div class="content">
<div class="location">{{contact.location}}</div>
<h1>{{contact.name}}</h1>
<h2>{{contact.role}}, {{contact.company}}</h2>
<p>{{contact.info}}</p>
{{contact.email}} |
<a
href="http://www.twitter.com/{{contact.twitter}}">@{{contact.twitter}}<
/a>
</div>
</div>
</ng-container>
@CraftAcademySE #CuriousCoder #CrashCourse
What happened?
Something awesome...
One more line.
In app.component.ts, on a
new line after line 17 (the one
with console.log on it), make
a new line:
this.data = data;
@CraftAcademySE #CuriousCoder #CrashCourse
@CraftAcademySE #CuriousCoder #CrashCourse
COPY / PASTE:
Head to this URL and copy everything:
http://bit.ly/2q9f8h0
Now paste it into /src/app/app.component.css
@CraftAcademySE #CuriousCoder #CrashCourse
Well done!
And that my friends, is that!
@CraftAcademySE #CuriousCoder #CrashCourse
Thank you!
Andy Carnahan
andrew@craftacademy.se
@CraftAcademySE #CuriousCoder #CrashCourse
www.craftacademy.co

More Related Content

PDF
Magento 2 Front-end performance tips & tricks - Meet Magento Romania 2017
PDF
STOP HACKERS & THIEVES
PDF
Creating Big Data: Methodology
DOCX
Safeguard our website and prevents from bad internet bots and scripts to expl...
PPTX
Web design 2 - Basic HTML 2010
PDF
Introduction to Big Data
PDF
AB Testing, Ads and other 3rd party tags - SmashingConf London - 2018
PDF
Magento 2 Front-end performance tips & tricks - Nomadmage September 2017
Magento 2 Front-end performance tips & tricks - Meet Magento Romania 2017
STOP HACKERS & THIEVES
Creating Big Data: Methodology
Safeguard our website and prevents from bad internet bots and scripts to expl...
Web design 2 - Basic HTML 2010
Introduction to Big Data
AB Testing, Ads and other 3rd party tags - SmashingConf London - 2018
Magento 2 Front-end performance tips & tricks - Nomadmage September 2017

Similar to Ca curious coder_crash_course (20)

PPTX
Presentation on angular 5
PPTX
AngularJS One Day Workshop
PDF
Mastering angular - Dot Net Tricks
PDF
Angular training-course-syllabus
PDF
Angular training-course-syllabus
PDF
Angular Up and Running Learning Angular Step by Step 1st Edition Shyam Seshadri
PDF
Angular js
PDF
Angular js
PDF
Start learning code with an idea
PDF
Angular Up and Running Learning Angular Step by Step 1st Edition Shyam Seshadri
PPTX
Getting Started with Angular JS
PDF
Download full ebook of Angular 2 Cookbook Frisbie instant download pdf
PDF
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
PDF
Angular 7 training_topics
PPTX
Good karma: UX Patterns and Unit Testing in Angular with Karma
PDF
Angular 2 overview in 60 minutes
PDF
Understanding router state in angular 7 passing data through angular router s...
PDF
Angular 7 Firebase5 CRUD Operations with Reactive Forms
PDF
Developing a Demo Application with Angular 4 - J2I
PDF
Mobile phone future angular js
Presentation on angular 5
AngularJS One Day Workshop
Mastering angular - Dot Net Tricks
Angular training-course-syllabus
Angular training-course-syllabus
Angular Up and Running Learning Angular Step by Step 1st Edition Shyam Seshadri
Angular js
Angular js
Start learning code with an idea
Angular Up and Running Learning Angular Step by Step 1st Edition Shyam Seshadri
Getting Started with Angular JS
Download full ebook of Angular 2 Cookbook Frisbie instant download pdf
[Ebooks PDF] download AngularJS 1st Edition Brad Green full chapters
Angular 7 training_topics
Good karma: UX Patterns and Unit Testing in Angular with Karma
Angular 2 overview in 60 minutes
Understanding router state in angular 7 passing data through angular router s...
Angular 7 Firebase5 CRUD Operations with Reactive Forms
Developing a Demo Application with Angular 4 - J2I
Mobile phone future angular js
Ad

Recently uploaded (20)

PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PPTX
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
International_Financial_Reporting_Standa.pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PDF
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
B.Sc. DS Unit 2 Software Engineering.pptx
Myanmar Dental Journal, The Journal of the Myanmar Dental Association (2013).pdf
AI-driven educational solutions for real-life interventions in the Philippine...
DRUGS USED FOR HORMONAL DISORDER, SUPPLIMENTATION, CONTRACEPTION, & MEDICAL T...
Hazard Identification & Risk Assessment .pdf
Unit 4 Computer Architecture Multicore Processor.pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
Journal of Dental Science - UDMY (2021).pdf
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
Introduction to pro and eukaryotes and differences.pptx
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
International_Financial_Reporting_Standa.pdf
Environmental Education MCQ BD2EE - Share Source.pdf
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
LIFE & LIVING TRILOGY - PART - (2) THE PURPOSE OF LIFE.pdf
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
Empowerment Technology for Senior High School Guide
Core Concepts of Personalized Learning and Virtual Learning Environments
Ad

Ca curious coder_crash_course

  • 1. What is an app and how do I make one? Coding for the Curious Crash Course Andy Carnahan andrew@craftacademy.se @CraftAcademySE #CuriousCoder #CrashCourse
  • 2. First, fill out this form: https://ca-address-book.herokuapp.com/ Your information will be shared with everyone in this room, but we’ll delete all your info in a couple days so nobody else gets it. @CraftAcademySE #CuriousCoder #CrashCourse
  • 3. Apps vs. Websites: It’s complicated A short summary: if you can log in, it’s an app. If you see the same information as every other visitor, it… may not be an app. @CraftAcademySE #CuriousCoder #CrashCourse
  • 5. Static sites. No forms. Primarily for showing information, not accepting it. Websites
  • 7. APIs: sending and receiving information between computer systems Application Programming Interface @CraftAcademySE #CuriousCoder #CrashCourse
  • 8. { contacts: [ { name: "Thomas Ochman", email: "thomas@craftacademy.se", company: "CraftAcademy", role: "Managers", twitter: "thomasochman", location: "Gothenburg", info: "Nothing...", image: "https://ca-address-book.herokuapp.com/images/desert.jpg" }, { name: "Raoul", email: "diraulo@craftacademy.se", company: "Craft Academy", role: "Chief computer wizard ;-)", twitter: "diraulo", location: "Pretoria", info: "Yeah well, you know... All round badass ", image: "https://ca-address-book.herokuapp.com/images/ocean.jpg" } ] } Our API https://ca-address-book.herokuapp.com/api/contacts @CraftAcademySE #CuriousCoder #CrashCourse
  • 9. Consuming our API with Angular! ● Do you have Node? In your terminal, type: $ node -v ● Now try: $ npm -v ● If those two commands gave you numbers, great! If not: https://nodejs.org/en/download/ @CraftAcademySE #CuriousCoder #CrashCourse
  • 10. We need a text editor, too www.atom.io @CraftAcademySE #CuriousCoder #CrashCourse
  • 11. Run these commands in your terminal: $ npm install -g @angular/cli When that finishes (you’ll get a prompt back with a $): $ ng new address-book When that one finishes (it will take a while): $ cd address-book Now open up Atom, navigate to the address-book folder and you should see a bunch of files. We’re almost ready to get coding! @CraftAcademySE #CuriousCoder #CrashCourse
  • 12. IGNORE:Everything that is not in the /src/app folder @CraftAcademySE #CuriousCoder #CrashCourse
  • 14. Fire up your server! Type in your terminal: ng serve Visit in your browser: localhost:4200 @CraftAcademySE #CuriousCoder #CrashCourse
  • 15. Get in the steering wheel. Open up /src/app/app.component.ts On line 9, you’ll see title = ‘app’ Look familiar? Change the text in quotes to anything your heart desires for instance “all workshop participants“ Now go back to your browser - you have just written code. @CraftAcademySE #CuriousCoder #CrashCourse
  • 16. Now, we’ll write some HTML. <ng-container class="container"> <div class="card"> <div class="image"> <img src="#"/> </div> <div class="content"> <div class="location">Gothenburg</div> <h1>Nils Magnusson</h1> <h2>CEO, NM.com</h2> <p>Nils is a great made-up guy.</p> nils@nils.com | <a href="http://www.twitter.com/nilsmagnusson">@nilsmagnusson</a> </div> </div> </ng-container> Put this into /src/app/app.component.html
  • 17. import { Component } from '@angular/core'; import { Http, Response } from '@angular/http'; import 'rxjs/add/operator/map'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'app'; data = {}; private apiUrl = 'https://ca-address-book.herokuapp.com/api/contacts'; constructor(private http: Http) { this.getContacts().subscribe(data => { console.log(data); }); } getContacts() { return this.http.get(this.apiUrl) .map((res: Response) => res.json()); } } Let’s do this. We need to edit /app/app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'app works!'; } @CraftAcademySE #CuriousCoder #CrashCourse
  • 18. If you just installed @angular/cli you also need to edit /app/app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { HttpModule } from '@angular/http'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, HttpModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
  • 19. Let’s remove the placeholders and grab real info in /src/app/app.component.html <ng-container *ngFor="let contact of data.contacts" class="container"> <div class="card"> <div class="image"> <img src="{{contact.image}}"/> </div> <div class="content"> <div class="location">{{contact.location}}</div> <h1>{{contact.name}}</h1> <h2>{{contact.role}}, {{contact.company}}</h2> <p>{{contact.info}}</p> {{contact.email}} | <a href="http://www.twitter.com/{{contact.twitter}}">@{{contact.twitter}}< /a> </div> </div> </ng-container> @CraftAcademySE #CuriousCoder #CrashCourse
  • 21. One more line. In app.component.ts, on a new line after line 17 (the one with console.log on it), make a new line: this.data = data; @CraftAcademySE #CuriousCoder #CrashCourse
  • 23. COPY / PASTE: Head to this URL and copy everything: http://bit.ly/2q9f8h0 Now paste it into /src/app/app.component.css @CraftAcademySE #CuriousCoder #CrashCourse
  • 24. Well done! And that my friends, is that! @CraftAcademySE #CuriousCoder #CrashCourse