An introduction to Angular 2

Slides:



Advertisements
Similar presentations
Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Advertisements

Introduction to ASP.NET MVC
Developing HTML5 Application using MVVM pattern Pekka Ylenius.
Writing better HTML5 websites and debugging them By Peter Messenger Senior Developer – Triple Point Technology
Kashif Jalal CA-240 (072) Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 2 of…
SharePoint Saturday Sponsors Gold Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
USING ANGULARJS WITH SITEFINITY
Agenda What is AJAX? What is jQuery? Demonstration/Tutorial Resources Q&A.
Presented by…. Group 2 1. Programming language 2Introduction.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
Title slide to be used at the start of a module. Developing Mobile Apps Roland Guijt
Philly.NET Hands-on Labs JAVASCRIPT SERIES. July 9: JavaScript Syntax Visual Studio ◦Projects ◦Editors ◦Debugging ◦Script blocks ◦Minification and bundling.
CIS 375—Web App Dev II ASP.NET 2 Introducing Web Forms.
May 16 – 18, 2007 Copyright 2007, Data Access Worldwide May 16 – 18, 2007 Copyright 2007, Data Access Worldwide Build Great Web Application 'Fast and Easy'
Introduction to Silverlight. Slide 2 What is Silverlight? It’s part of a Microsoft Web platform called Rich Internet Applications (RIA) There is a service.
Angelo Chan Kamran Bilgrami. Agenda ● WinJS - What and Why ● Modern Apps ● WinRT Architecture ● Demos o Controls o Data Bindings o Program LifeCycle Management.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
Introducing NativeScript [Pavel Kolev Software Telerik: a Progress company]
INTRODUCTION TO HTML5 Using jQuery with HTML5. Introducing jQuery  Although it is not a part of any W3C or WHATWG specification, jQuery performs an important.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
Sponsors Gold Silver Bronze Custom REST services and jQuery AJAX Building your own custom REST services and consuming them with jQuery AJAX.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
Using NativeScript to develop native apps for IOS and Android
Game on! With Nativescript
UNDERSTANDING YOUR OPTIONS FOR CLIENT-SIDE DEVELOPMENT IN OFFICE 365 Mark Rackley
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
NativeScript – Open source platform to build Native iOS/Android Apps.
Getting Started with Angular 2 and TypeScript Nebraska.Code() 2016 Spencer Schneidenbach Ryvit.
Modern Development Technologies in SharePoint SHAREPOINT SATURDAY OMAHA APRIL, 2016.
The New Face of ASP.NET ASP.NET MVC, Razor, and jQuery Ido Flatow | Senior Architect | Sela | This session is.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
Introduction ITEC 420.
Building Desktop Apps with Node.js and Electron
Learning About Angular
Angular 2 with ASP.NET Core in Practice
Visual Studio 2017 By Michael Washington
Angular 4 + TypeScript Getting Started
WWU Hackathon May 6 & 7.
What's new in the world of SharePoint development and deployment
Introduction to ASP.NET 2.0
TechEd /1/2018 7:56 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Working with Client-Side Scripting
ASP.NET Core Tag Helpers
Introduction to TypeScript & Angular
Haritha Dasari Josue Balandrano Coronel -
The Cliff Notes Version
Introduction to Silverlight
Building Native Mobile Apps with Angular 2.0 and NativeScript
Introduction to SharePoint Framework (SPFx)
A lot of Software Development is about learning
Seamless Upgrade to Angular 5. Team at Google released the new version of angular that is Angular 5.0.0, pentagonal-donut. The main three insights that.
Angularjs Interview Questions and Answers By Hope Tutors.
Microsoft Ignite NZ October 2016 SKYCITY, Auckland.
Web Development Using ASP .NET
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JavaScript CS 4640 Programming Languages for Web Applications
Angular 2 : CRUD Operations
Angular 2 Michael C. Kang.
An Introduction to JavaScript
Introduce to Angular 6 Present by: Võ Văn Hào
Web Client Side Technologies Raneem Qaddoura
Introduction to ASP.NET Parts 1 & 2
Running C# in the browser
Blazor A new framework for browser-based .NET apps Ryan Nowak
JavaScript CS 4640 Programming Languages for Web Applications
Presentation transcript:

An introduction to Angular 2 Peter Messenger Senior Developer at Kip Mc Grath Education Services Email : stonecourier@gmail.com Twitter: stonecourier Website : www.petermessenger.com

My Development History Lots of work with C#, HTML and JavaScript Originally worked on webforms Moved on Single Page applications (Knockout JS) Worked on developing Silverlight Applications Worked on MVC apps, JQuery front ends Worked with Typescript extensively Presented a coders on Windows Phone, Android, Silverlight, Knockout, MVVM, JQuery Mobile/UI Typescript, Nativescript + more

Application I am working on Teaching portal, setting up and doing lessons collaboratively Technology Angular 2 Front End Kids (5 years and up) Dev Express Components People with reading or learning difficulties Socket IO, Video conferencing functionality Approximately 650 centres around Australia ASP NET core web api back end 40,000+ students per week Replacing Also other countries – England, New Zealand, Singapore etc JQuery/JavaScript Front End Mix of lots of libraries MVC Back end

What is Angular 2? Angular 1 was originally developed in 2009 Angular 2 rewrite was originally started in Sept 2014 Released after long beta testing in Sept 2016 Very popular JavaScript framework for creating web applications Can also be used to develop native apps using Nativescript, Ionic framework etc Developed by Google using Typescript (a “typed” subset of javascript from Microsoft)

Angular 2 Popularity

Benefits of Angular 2 - Typescript Compile time type checking, intellisense export interface IListItem { someText: string; someNumber: number; someDate: number; arrayOfStrings: string[]; } export class AppComponent { listItems: IListItem[]; }

Typescript Classes, Interfaces, Enums, Functions Inheritance, Generics Private, Public, Protected Namespaces, Modules Changes JavaScript for the better (more like C#) Personally, Do not want to develop “vanilla” JavaScript ever again. See more at https://www.typescriptlang.org/

Benefits of Angular 2 Complete framework for developing apps Components – building blocks for apps Input, Output Templates Services (http and more) Dependency Injection Observables Routing, Forms and Modules (skipping explanation of these in this presentation) Get more information at https://angular.io/docs/ts/latest/guide/

Benefits of Angular 2 - Components Develop components – promotes clean testable code import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: `<h1>Hello {{name}}</h1>` }) export class AppComponent { name = 'Angular'; }

Benefits of Angular 2 - Events @Component({ selector: 'my-app', template: `<button (click)=“sayHello()”></button>` }) export class AppComponent { sayHello() { alert(“Hello); }

Benefits of Angular 2 - Input export class AppComponent { @Input() name = 'Angular'; } Can pass in data from the html <my-app name=“some other name”></my-app> Can also do binding <my-app [name]=“myBoundVariable”></my-app> Can also do two-way binding <my-app [(name)]=“myBoundVariable”></my-app>

Benefits of Angular 2 - Output export class AppComponent { @Output() onSpecialEvent: EventEmitter<string> = new EventEmitter<string>(); specialEvent(value: string) { this.onSpecialEvent.emit(value); } Can pass in data from the html <my-app (onSpecialEvent)=“myCustomHandler($event)”></my-app>

Benefits of Angular 2 - Templates Inline File Reference (my preference) @Component({ selector: 'my-app', template: ` <h1>{{title}}</h1> <h2>My favorite hero is: {{myHero}}</h2> `}) @Component({ selector: "kip-enrolment- wizard", templateUrl: "enrolmentwizard.html", styleUrls: ["enrolmentwizard.css"], })

Benefits of Angular 2 - Templates <div [class.extra- sparkle]="isDelightful"> <div [style.width.px]="mySize"> <p>Employer: {{employer?.company Name}}</p> Binds the presence of the CSS class extra-sparkle on the element to the truthiness of the expression isDelightful Binds style property width to the result of expression mySize in pixels The safe navigation operator (?) means that the employer field is optional and if undefined, the rest of the expression should be ignored.

Benefits of Angular 2 – Templates continued <section *ngIf="showSection"> <li *ngFor="let item of list"> <div [ngSwitch]="conditionExpression">   <template [ngSwitchCase]="case1Exp">...</te mplate>   <template ngSwitchCase="case2LiteralString">. ..</template>   <template ngSwitchDefault>...</template> </div> See more at https://angular.io/docs/ts/latest/guide/cheatsheet.html Removes or recreates a portion of the DOM tree based on the showSection expression. Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list. Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of conditionExpression.

Benefits of Angular 2 – Services/Injectable Can make helper service classes These can provide a data access layer via http (these work really well with ASP NET core web api) Can use observables (can subscribe to monitor changes) someVariable.subscribe((changes)=>{}); Can use promises soSomething(action).then((result)=>{}); Anything you can think of These can be injected into your components Makes it easy to mock and test

Benefits of Angular 2 – Services/Injectable import { Injectable } from '@angular/core'; import { HEROES } from './mock-heroes'; @Injectable() export class HeroService { getHeroes() { return HEROES; } } ------------------------ export class HeroListComponent { heroes: Hero[]; constructor(heroService: HeroService) { this.heroes = heroService.getHeroes(); import { Hero } from './hero'; export var HEROES: Hero[] = [ { id: 11, isSecret: false, name: 'Mr. Nice' }, { id: 12, isSecret: false, name: 'Narco' }, { id: 13, isSecret: false, name: 'Bombasto' }, { id: 14, isSecret: false, name: 'Celeritas' }, { id: 15, isSecret: false, name: 'Magneta' }, { id: 16, isSecret: false, name: 'RubberMan' }, { id: 17, isSecret: false, name: 'Dynama' }, { id: 18, isSecret: true, name: 'Dr IQ' }, { id: 19, isSecret: true, name: 'Magma' }, { id: 20, isSecret: true, name: 'Tornado' } ];

Benefits of Angular 2 – Observables & State Uses RxJs to simplify asynchronous code Observables, Promises and more Almost a complete presentation in itself State Libraries like ngrx/store allow you to manage the entire state of your application simply https://github.com/ngrx/store

Visual Studio Code Use Visual Studio Code (free) https://code.visualstudio.com/ Built in Git Hub integration Plugins help write better code TS Lint helps developers write better code – you can turn on/off rules to suit your coding style

Quick Code Demo Showing NCG Demo

Compiling your Application An Angular application consist largely of components and their HTML templates. Before the browser can render the application, the components and templates must be converted to executable JavaScript by the Angular compiler. You can compile the app in the browser, at runtime, as the application loads, using the Just-in-Time (JIT) compiler. JIT compilation incurs a runtime performance penalty. Views take longer to render because of the in-browser compilation step. The application is bigger because it includes the Angular compiler and a lot of library code that the application won't actually need. Bigger apps take longer to transmit and are slower to load. Compilation can uncover many component-template binding errors. JIT compilation discovers them at runtime which is later than we'd like.

Ahead of Time Compilation Faster rendering With AOT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first. Fewer asynchronous requests The compiler inlines external html templates and css style sheets within the application JavaScript, eliminating separate ajax requests for those source files. Smaller Angular framework download size There's no need to download the Angular compiler if the app is already compiled. The compiler is roughly half of Angular itself, so omitting it dramatically reduces the application payload. Detect template errors earlier The AOT compiler detects and reports template binding errors during the build step before users can see them. Better security AOT compiles HTML templates and components into JavaScript files long before they are served to the client. With no templates to read and no risky client-side HTML or JavaScript evaluation, there are fewer opportunities for injection attacks.

Treeshaking – Making application smaller Tree shaking is the ability to remove any code that we are not actually using in our application from the final bundle. It's one of the most effective techniques to reduce the footprint of an application. You may think “all my code is being used!” Third party libraries Redundant code etc Done using Webpack 2. Can be included as part of the build process Very easily done using……

Angular Command Line Interface Use angular cli (command line interface) https://github.com/angular/angular-cli Automatic change detection, can just change code while you are developing and your browser will automatically be refreshed Built in commands to create components, directives etc Run karma tests Run full project linting Automates build process Ahead of time compilation Copies all the files you need to make deployment easy Joins all the files together and “tree-shakes” your code to make it a small as possible Automates css/js compression

Angular Cli Getting Started npm install –g angular-cli ng new new-app cd new-app ng serve Other Commands ng generate …. (components, routes, services) ng build -- prod ng build -- dev

Angular Cli build output Creates file with guid names based on if content has changed Makes caching easy Splits up scripts (your code, reference libraries etc) Can make it include files as required Copy to server and it will just work

Component Frameworks Many component vendors Telerik - http://www.telerik.com/kendo-angular-ui/ Wijmo - http://wijmo.com/angular2/ Dev Extreme - https://www.npmjs.com/package/devextreme-angular Material - https://material.angular.io/ Most are still a work in progress We are currently using Dev Extreme (as they are reusing their old code base, they are more complete)

Quick Demo of Application Demonstrate Speed Translation Services Security

Questions? Presentation will be up on my site Looking for employment www.petermessenger.com Looking for employment Want to work on Angular 2 Project? Come and see me, Kip McGrath is hiring.