24
ANGULAR 2 / ASP.NET CORE PRIMER [email protected]

ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

Embed Size (px)

Citation preview

Page 1: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ANGULAR 2 / ASP.NET CORE PRIMER

[email protected]

Page 2: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

AGENDA

• Get started with developing angular 2 applications using ASP.NET core in visual studio 2015.

• Learn the basics of angular 2 and ASP.NET core.

• Look at creating Web Api web services using MVC functionality of ASP.NET core and Entity

Framework Core. Finish up with learning where to go from the primer to continue studying the

new web stack.

Page 3: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ASP.NET CORE MVC/ WEB API

• HTTP and Web Services

• Web Api is merged with MVC in MVC Core /6

• Cross platform

• It consists of classes that expose data through methods

• It is an abstraction on top of HTTP

• Dependency Injection

Page 4: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

CONTROLLERS

• Controllers are at the heart of Web Api / MVC 6

• Methods are loosely equal to web requests

• Methods support parameters and return values

• Can be asynchronous or synchronous

Page 5: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ENTITY FRAMEWORK

• Entity Framework is Microsoft’s answer to ORM

• Performant, cross platform, new from the ground up

• Providers - multiple back ends are supported

• Configuration

• Data annotations

• Configuration fluent Api

Page 6: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

PROJECT

• Structure

• TypeScript configuration

• Gulp (optional)

Page 7: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

WHAT IS ANGULAR

• “Superheroic MVW framework” http://angularjs.org/

• Sponsored by Google

• Open source

Page 8: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ANGULAR FEATURES AND COMPONENTS

• Data binding - controllers, scope

• Directives - HTML DOM manipulation

• Services – reusable components, dependency injection

• HTML forms with validation

• HTTP requests

• Navigation

• Extensibility

Page 9: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

WHY ANGULAR 2?

• Complete re-write

• Built for speed

• Memory efficient

• Smaller library

Page 10: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

WHAT’S DIFFERENT AND NEW IN ANGULAR 2

• Data binding to properties and events with new syntax

• Component based ~ angular 1.X controllers plus template directive

• Unidirectional data flow with Rx (reactive extensions)

• Written in typescript, can be used with ES5, ES6 and typescript

• New tooling: angular CLI , Augury(Batarangle)

• Can integrate with angular 1, ngupgrade

• Supports IE9+ and other modern browsers

Page 11: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ANGULAR 2 COMPONENT

• Is a TypeScript class

• Metadata via decorators

• @Component

• Template

• Selector

• Logic

• Components all the way down

• Inputs / outputs / events

Page 12: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

DATA BINDING

• Component exposed to template

• Types

• Interpolation: {{name}}

• Property [name]

• Event (click)=“dosomething()”

• Two way = [(ngmodel)]=“name”

Page 13: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

SERVICE

• Similar to angular 1, an injectable

• Plain typescript class

• Cross cutting concerns

Page 14: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

NGMODULE

• Typescript class

• Package of components, services and directives

@NgModule({

imports: [CommonModule, HttpModule, ContactRouting, FormsModule, SharedModule],

declarations: [ContactList, ContactListItem, Contacts, ContactEdit],

providers: [Configuration, HttpModule, ContactService],

exports: [ContactList]

})export class ContactModule { }

Page 15: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

BOOTSTRAPPING THE APP

• Root component

• Root module

• System.js

• Gulp

• AOT compilation / ng CLI

Page 16: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

DIRECTIVES

• Components

• Structural

• Attribute

Page 17: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

PIPES

• Pure

• Asynchronous

• Support parameters and chaining

Page 18: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

BUILT-IN PIPES

• Currency

• Json

• Percent

• Slice

• Date

• Lower case

• Upper case

• Decimal

• Number

• Async

Page 19: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

NAVIGATION

• Client side routing

• Deep linking

• Route definition

• URL

• Components

• Etc…

• Navigation via

• Router Link directive

• In Code

• Router Outlet

Page 20: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

FORMS

• Types

• Template driven

• Reactive Api

Page 21: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

NEXT STEPS

• Testing with Jasmin

• CLI

Page 22: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ANGULAR CLI

• Scaffolding / quick starts

• Building, including Web Pack and tree shaking

• Server side “compilation”

• Testing with Karma

• Linting (error checking) and formatting

• Scaffolding / quick starts• Building, including Web Pack and tree

shaking• Server side “compilation”• Testing with Karma• Linting (error checking) and formatting• More to come

Page 23: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

ASP.NET CORE CLI

• Scaffolding

• Build

• Run

• Restore packages

Page 24: ASP.NET Core and Angular 2 · Microsoft PowerPoint - ASP.NET Core and Angular 2.pptx Author: serge Created Date: 1/14/2017 3:35:48 PM

DEVELOP

• Mac or Windows

• Any Editor

• Follow projects on GitHub

• Shameless plug - https://www.packtpub.com/web-development/angular-2-web-development-

typescript-video