Introduction to Angular with TypeScript for .NET Developers

44
Laurent Duveau March 15 th , 2017

Transcript of Introduction to Angular with TypeScript for .NET Developers

Page 1: Introduction to Angular with TypeScript for .NET Developers

Laurent DuveauMarch 15th, 2017

Page 2: Introduction to Angular with TypeScript for .NET Developers

2

Page 3: Introduction to Angular with TypeScript for .NET Developers

@LaurentDuveau

MVP, RD

I live in Montreal (wait for next slide…)

Founder of the Angular Academy

2-day Angular Classroom Training

55 classes in the last 18 months

Montreal, Boston, Quebec, Toronto, Ottawa , Vancouver, Calgary, London, Copenhagen, …

Page 4: Introduction to Angular with TypeScript for .NET Developers

4

Page 5: Introduction to Angular with TypeScript for .NET Developers

TypeScript

Setup and Tooling

Angular

Page 6: Introduction to Angular with TypeScript for .NET Developers
Page 7: Introduction to Angular with TypeScript for .NET Developers

THIS TALK IS ABOUT…

Page 8: Introduction to Angular with TypeScript for .NET Developers

.NET Developer

Page 9: Introduction to Angular with TypeScript for .NET Developers
Page 10: Introduction to Angular with TypeScript for .NET Developers
Page 11: Introduction to Angular with TypeScript for .NET Developers

ANGULAR IS BUILT USING TYPESCRIPT

Page 12: Introduction to Angular with TypeScript for .NET Developers

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript

You can combine Javascript with Typescript

Any browser. Any host. Any OS

It is a Microsoft Technology, Open Source

From the creator of C#

12

Page 13: Introduction to Angular with TypeScript for .NET Developers

Wait…

Page 14: Introduction to Angular with TypeScript for .NET Developers

TypeScriptfile.ts

JavaScriptfile.js

TypeScript Compiler

Output ES5/ES6/… compliant code

“Transpiling”

Page 15: Introduction to Angular with TypeScript for .NET Developers

I hate JavaScript…TypeScript is here

to help!

.NET Dev Mom

Page 16: Introduction to Angular with TypeScript for .NET Developers

let height:number = 6;let isDone:boolean = true;let name:string = "Angular Academy";let list:number[] = [1, 2, 3];

16

Page 17: Introduction to Angular with TypeScript for .NET Developers

let list: Array<number>;list = [17, 99, 42]; // OK

let cpt: number|string;cpt = 123; // OKcpt = "123"; // OK

17

Page 18: Introduction to Angular with TypeScript for .NET Developers

class Auto

constructor(private _engine:string)

get engine():string return this._engine;

set engine(val:string) this._engine = val;

start() console.log("Take off using: " + this._engine);

constructor

get/set property

blocks

method

Page 19: Introduction to Angular with TypeScript for .NET Developers

DEMONSTRATION

Page 20: Introduction to Angular with TypeScript for .NET Developers
Page 21: Introduction to Angular with TypeScript for .NET Developers

21

Page 22: Introduction to Angular with TypeScript for .NET Developers

22

Page 23: Introduction to Angular with TypeScript for .NET Developers

23

> npm install XYZ

Page 24: Introduction to Angular with TypeScript for .NET Developers

24

Page 25: Introduction to Angular with TypeScript for .NET Developers

Getting started faster!

25

> npm install -g @angular/cli

> ng new DemoAngular

> ng serve

cli.angular.io

Page 26: Introduction to Angular with TypeScript for .NET Developers

There’s a new kid in town!

VS Code… a code editor, not an IDE

Free, Open Source

Windows, Mac, Linux!

HTML5, CSS, LESS, JavaScript or C# with NodeJs or ASP.NET, …

Rich code editor from VS in a fast and lightweight tool

Debug, deploy

Git integration

Extensions

code.visualstudio.com

Page 27: Introduction to Angular with TypeScript for .NET Developers

DEMONSTRATION

Page 28: Introduction to Angular with TypeScript for .NET Developers
Page 29: Introduction to Angular with TypeScript for .NET Developers

JavaScript Framework especially suitable for single-page modern web applications (Single Page Application, or SPA)

Compatible with Internet Explorer 9+ and others modern browsers

Open Source, MIT license

www.angular.io

Page 30: Introduction to Angular with TypeScript for .NET Developers

* based on v2 architecture released in September 14, 2016

Angular 4.0.0-RC.3! *

Page 31: Introduction to Angular with TypeScript for .NET Developers

31

JavaScript,

HTML,

CSS, …

Angular is here

REST API,

ASP.NET,

C#, …

Your DB is

there!

Where is

TypeScript ?

Page 32: Introduction to Angular with TypeScript for .NET Developers

Components ModulesDependency

Injection

Language

(TypeScript)

Services Data Binding Decorators Routing

Page 33: Introduction to Angular with TypeScript for .NET Developers

Header Component

Menu

Component

Footer Component

List ComponentGrid Component

Page 34: Introduction to Angular with TypeScript for .NET Developers

YOUR APP IS A TREE OF

COMPONENTS

Page 35: Introduction to Angular with TypeScript for .NET Developers

Map Update

App

DetailsList

ProductsMenu Contact

Page 36: Introduction to Angular with TypeScript for .NET Developers
Page 37: Introduction to Angular with TypeScript for .NET Developers

A component is a reusable object

Made up of: HTML

Template

Code

(ts class)

Page 38: Introduction to Angular with TypeScript for .NET Developers
Page 39: Introduction to Angular with TypeScript for .NET Developers
Page 40: Introduction to Angular with TypeScript for .NET Developers

DEMONSTRATION

Page 41: Introduction to Angular with TypeScript for .NET Developers

Visual Studio 2015 QuickStarthttp://tinyurl.com/jmhv9h8

Angular setup with VS 2015 and ASP.NET 4 http://tinyurl.com/h2n82v8

ASP.NET Core + Angular template for VShttp://tinyurl.com/jnoqwfs

Deploy an Angular/ASP.NET Core App to Azure http://tinyurl.com/he4g8lb

41

Page 42: Introduction to Angular with TypeScript for .NET Developers

Thank you!

Page 43: Introduction to Angular with TypeScript for .NET Developers
Page 44: Introduction to Angular with TypeScript for .NET Developers