57
Getting Started With The Angular 2 CLI July 2016 by Jim Lynch

Getting Started with the Angular 2 CLI

Embed Size (px)

Citation preview

Page 1: Getting Started with the Angular 2 CLI

Getting Started With The

Angular 2 CLIJuly 2016

by Jim Lynch

Page 2: Getting Started with the Angular 2 CLI

Jim LynchFront-End Engineer at Altered Image

@webWhizJim

http://www.slideshare.net/JimLynch22/getting-started-with-the-angular-2-cli

WebStorm Ambassador

“The BDD Angular Guy”Slides available here:

Page 3: Getting Started with the Angular 2 CLI

Resources for Learning Angular 2

https://www.udemy.com/angular-2-crash-course/learn/v4/?

couponCode=blackhat&pmtag=CELEBRATE40&utm_source=codek.tv

1. Angular 2 Crash Course with TypeScript - UdemyFree with the link below!

Page 4: Getting Started with the Angular 2 CLI

Resources for Learning Angular 2

2. Accelerating Through Angular 2 - CodeSchool.com

https://www.codeschool.com/courses/accelerating-through-angular-2

(First level free, then requires pro membership)

Page 5: Getting Started with the Angular 2 CLI

Resources for Learning Angular 2

3. Pluralsight Courses(requires pluralsight membership)

Page 6: Getting Started with the Angular 2 CLI

Resources for Learning Command Line / BASH

2 Free Code School Courses!

- Shell Productivity Elective Course

- Unix Basics Elective Course

https://www.codeschool.com/

Page 7: Getting Started with the Angular 2 CLI

Resources for Learning Command Line / BASH

Free Code Camp Backend Challenges

Free!

Page 8: Getting Started with the Angular 2 CLI

Resources for Learning Command Line / BASH

• Reference guide of the common Unix / Linux commands.

• Physically small book.

• Humorous yet informative and technical descriptions.

Page 9: Getting Started with the Angular 2 CLI

Resources Specifically For Learning Angular 2 CLI

• Angular CLI Reference PDF (https://cli.angular.io/reference.pdf)

• Angular 2 CLI Github Project Page (https://github.com/angular/angular-cli)

• Official Angular CLI Website (https://cli.angular.io/)

Page 10: Getting Started with the Angular 2 CLI

The Importance of Having a Pretty Command Line

• Your command line is a powerful tool. You should use it often and be comfortable with it.

• Make the background and font color easy on the eyes and increase the font size.

• Edit your ~/.bash_rc or ~/.bash_profile to make your text more colorful and change your BASH prompt.

• Install vim plugins for syntax highlighting.

Page 11: Getting Started with the Angular 2 CLI

So, What is Angular 2?

Page 12: Getting Started with the Angular 2 CLI

What Is a SPA Framework?

Routing

- Illusion of Pages

- Deep Linking

- Layers of HTML

Components

- Ties HTML to JS

- Data Binding

- Modular Code

Page 13: Getting Started with the Angular 2 CLI

Angular 2 Building Blocks

• Pipes

• Services

• Routes

• Components• Directives

(Eerily similar the building blocks of AngularJS)

• Filters

• Services

• Routes

• Controllers• Directives

Page 14: Getting Started with the Angular 2 CLI

Differences From Angular 1• No more “ng-“ directives! New syntax for binding

directly to events instead.• Namespaced CSS / Sass

• Simpler concept of Directives, No link functions in ng2!

• Nice router with power and flexibility of UI-Router

• Crazy fast with Shadow DOM under the hood.

• And best of all, the Angular CLI!

• Projects are written in TypeScript (usually).

• Observables to handle streams and cancel requests!

Page 15: Getting Started with the Angular 2 CLI

If You Can’t Beat Em’, Join em’. (Or just copy ‘em)

• Concept of “Shadow DOM” originally from React

• Took Microsoft’s TypeScript and made it mainstream.

• CLI tool ported from from Ember CLI.

Page 16: Getting Started with the Angular 2 CLI

The Angular CLI!!Are you as excited as this guy?

Page 17: Getting Started with the Angular 2 CLI

Use the command line to generate folders and files for you.

…or even generate an entire starter project.

The Main Idea

Page 18: Getting Started with the Angular 2 CLI

The Initiation Ceremony (Installing angular-cli)

This is where your Angular 2 CLI journey begins!

Page 19: Getting Started with the Angular 2 CLI

If You Get This Error:You might get this error:

Error: EACCES: permission denied, open '/Users/jim/.config/configstore/ember-cli.json'

You don't have access to this file.

Give your current user ownership of

ember-cli.json sudo chown jim /Users/jim/.config/configstore/ember-cli.json

Page 20: Getting Started with the Angular 2 CLI

ng new

Page 21: Getting Started with the Angular 2 CLI

ng init

Page 22: Getting Started with the Angular 2 CLI

What Just Happened?

An entire starter project was scaffolded!

Page 23: Getting Started with the Angular 2 CLI

All these files and folders

were generated by

ng new!

Page 24: Getting Started with the Angular 2 CLI

A Closer Look

a What Was Created

Page 25: Getting Started with the Angular 2 CLI

ConfigEnvironment files for setting production boolean

environment variable.

Configuration files for automated test runners.

Page 26: Getting Started with the Angular 2 CLI

DistFolder that gets written to by build task

Contains final, minified files that get hosted to be the final, live product.

Page 27: Getting Started with the Angular 2 CLI

E2e

Contains files for e2e and integration tests run by Protractor.

Page 28: Getting Started with the Angular 2 CLI

node_modulesContains all the npm libraries that are dependencies

for your application.

Page 29: Getting Started with the Angular 2 CLI

PublicContains the .gitignore file.

A place for images and other static assets.

Some people like to put manually added libraries here.

Page 30: Getting Started with the Angular 2 CLI

SrcContains all of your source code!

Page 31: Getting Started with the Angular 2 CLI

TmpContains temporary files that Angular CLI

generates and uses to runs its tasks.

Page 32: Getting Started with the Angular 2 CLI

typingsContains TypeScript type definition files.

Page 33: Getting Started with the Angular 2 CLI

Other files

Other configuration files.

Page 34: Getting Started with the Angular 2 CLI

Workflow Commands

- ng serve

- ng test

- ng e2e

- ng build

Page 35: Getting Started with the Angular 2 CLI

ng serve

Page 36: Getting Started with the Angular 2 CLI

ng test

Page 37: Getting Started with the Angular 2 CLI

ng e2e

Page 38: Getting Started with the Angular 2 CLI

ng build

Page 39: Getting Started with the Angular 2 CLI

ng deploy gh:pages

Page 40: Getting Started with the Angular 2 CLI

Creating a Github TokenIt’s easy!

Page 41: Getting Started with the Angular 2 CLI

ng Generate!

• Scaffold individual components, routes, directives, services, or pipes!

• Alias for the generate command is just the letter g.

• The generated component has its own directory, unless the --flat options is specified.

Page 42: Getting Started with the Angular 2 CLI

ng g component

Page 43: Getting Started with the Angular 2 CLI

ng g service

Page 44: Getting Started with the Angular 2 CLI

ng g pipe

Page 45: Getting Started with the Angular 2 CLI

ng g directive

Page 46: Getting Started with the Angular 2 CLI

ng g route

Page 47: Getting Started with the Angular 2 CLI

CLI Bonus Commands!

Page 48: Getting Started with the Angular 2 CLI

ng-lint

Page 49: Getting Started with the Angular 2 CLI

ng help

Page 50: Getting Started with the Angular 2 CLI

ng doc <keyword>

Page 51: Getting Started with the Angular 2 CLI

ng version

Page 52: Getting Started with the Angular 2 CLI

Things You Might Consider Adding to An

Angular 2 Project

• Angular Universal / App Shell

• CucumberJS / Acceptance tests

• Redux or any other Flux Store

• Ionic / Angular for Native Apps

Page 53: Getting Started with the Angular 2 CLI

Other Generators

Do Exist!

Page 54: Getting Started with the Angular 2 CLI

Angular Universal Starter

Page 55: Getting Started with the Angular 2 CLI

FountainJS

Page 56: Getting Started with the Angular 2 CLI

Questions?

twitter.com/webWhizJim

www.wisdomofjim.com

Slides available here: www.slideshare.net/JimLynch22/getting-started-with-the-

angular-2-cli

github.com/JimTheMan

Page 57: Getting Started with the Angular 2 CLI

Thanks!