SlideShare a Scribd company logo
1 of 26
Download to read offline
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

Similar to Ca curious coder_crash_course

Your first web application. From Design to Launch
Your first web application. From Design to LaunchYour first web application. From Design to Launch
Your first web application. From Design to LaunchDavid Brooks
 
Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017Christian Heilmann
 
Progressive web and the problem of JavaScript
Progressive web and the problem of JavaScriptProgressive web and the problem of JavaScript
Progressive web and the problem of JavaScriptChristian Heilmann
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)Bramus Van Damme
 
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkNot Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkcrystalenka
 
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"IT Event
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud MessagingAshiq Uz Zoha
 
Building with JavaScript - write less by using the right tools
Building with JavaScript -  write less by using the right toolsBuilding with JavaScript -  write less by using the right tools
Building with JavaScript - write less by using the right toolsChristian Heilmann
 
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015Suzzicks
 
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015MobileMoxie
 
Mobile-First Indexing and AMP - SMX Advanced 2018
Mobile-First Indexing and AMP - SMX Advanced 2018Mobile-First Indexing and AMP - SMX Advanced 2018
Mobile-First Indexing and AMP - SMX Advanced 2018Alexis Sanders
 
Intro To Django
Intro To DjangoIntro To Django
Intro To DjangoUdi Bauman
 
Angular js mobile jsday 2014 - Verona 14 may
Angular js mobile   jsday 2014 - Verona 14 mayAngular js mobile   jsday 2014 - Verona 14 may
Angular js mobile jsday 2014 - Verona 14 mayLuciano Amodio
 
How to bake an app in Dart and Polymer
How to bake an app in Dart and PolymerHow to bake an app in Dart and Polymer
How to bake an app in Dart and PolymerJana Moudrá
 

Similar to Ca curious coder_crash_course (20)

Your first web application. From Design to Launch
Your first web application. From Design to LaunchYour first web application. From Design to Launch
Your first web application. From Design to Launch
 
Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017Leveling up your JavaScipt - DrupalJam 2017
Leveling up your JavaScipt - DrupalJam 2017
 
Progressive web and the problem of JavaScript
Progressive web and the problem of JavaScriptProgressive web and the problem of JavaScript
Progressive web and the problem of JavaScript
 
Resume-REBAI.json
Resume-REBAI.jsonResume-REBAI.json
Resume-REBAI.json
 
JavaScript isn't evil.
JavaScript isn't evil.JavaScript isn't evil.
JavaScript isn't evil.
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 
SxSW 2015
SxSW 2015SxSW 2015
SxSW 2015
 
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS frameworkNot Just a Pretty Face: How to design and build a cross-CMS CSS framework
Not Just a Pretty Face: How to design and build a cross-CMS CSS framework
 
SMX_DevTools_Monaco_2.pdf
SMX_DevTools_Monaco_2.pdfSMX_DevTools_Monaco_2.pdf
SMX_DevTools_Monaco_2.pdf
 
Seven Reasons for Code Bloat
Seven Reasons for Code BloatSeven Reasons for Code Bloat
Seven Reasons for Code Bloat
 
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
Sara Harkousse - "Web Components: It's all rainbows and unicorns! Is it?"
 
ajay
ajayajay
ajay
 
Google Cloud Messaging
Google Cloud MessagingGoogle Cloud Messaging
Google Cloud Messaging
 
Building with JavaScript - write less by using the right tools
Building with JavaScript -  write less by using the right toolsBuilding with JavaScript -  write less by using the right tools
Building with JavaScript - write less by using the right tools
 
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
 
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
Why Deep Linking is the Next Big Thing: App Indexing - SMX East 2015
 
Mobile-First Indexing and AMP - SMX Advanced 2018
Mobile-First Indexing and AMP - SMX Advanced 2018Mobile-First Indexing and AMP - SMX Advanced 2018
Mobile-First Indexing and AMP - SMX Advanced 2018
 
Intro To Django
Intro To DjangoIntro To Django
Intro To Django
 
Angular js mobile jsday 2014 - Verona 14 may
Angular js mobile   jsday 2014 - Verona 14 mayAngular js mobile   jsday 2014 - Verona 14 may
Angular js mobile jsday 2014 - Verona 14 may
 
How to bake an app in Dart and Polymer
How to bake an app in Dart and PolymerHow to bake an app in Dart and Polymer
How to bake an app in Dart and Polymer
 

Recently uploaded

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Recently uploaded (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 

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