SlideShare a Scribd company logo
1 of 60
Download to read offline
End-to-End SPA Development
using ASP.NET and AngularJS
Gil Fink
CEO and Senior Consultant, sparXys
Single Page Applications
Managers and SPA
Trying to solve the puzzle of single page application…
Even the Shortened Name
is Misleading…
Let’s build a SPA?
About Me
• sparXys CEO and Senior consultant
• ASP.NET/IIS Microsoft MVP
• Co-author of Pro Single Page Application
Development (Apress)
• Co-author of 4 Microsoft Official Courses (MOCs)
• Co-organizer of GDG Rashlatz
Agenda
• The Road to Single Page Applications
• What is a SPA?
• SPA Building Blocks
• ASP.NET MVC/Web API in the Backend
• AngularJS in the Front-End
The Road to SPAs
1990
HTML
HTTP
1995
Java
Applets
1996
CSS
JavaScript
Flash
1997
HTML 4
2005
Ajax is a
buzzword
2006
work on
HTML5
starts
2007
Silverlight
Mobile Web
Traditional Websites
OMG! not this kind of traditional website please!
Traditional Native Apps
Native apps – we love installation experience… Not!
What is a SPA?
Web Application
No full page
submit
No full page
refresh
No embedded
objects
(plugins)
Client-side
templating
and routing
Why to Develop SPAs?
Feature Web App Native App Single Page
App
Cross Platform
functionality
V X V
Client State
Management
X V V
No Installation
required
V X V
Web
App
Native
App
SPA
SPA Building Blocks
HTML5
JavaScript Libraries
Ajax
REST
SPA
Web API
Routing
HTML5
• Supported by most modern browsers
o www.caniuse.com
• Includes new JavaScript APIs that can help to:
o Store data locally
o Persist data across application shutdowns
o Communicate with the server in new ways
o Increase web performance with new specifications and APIs
Ajax
• Asynchronous JavaScript and XML
o No XML these days…
o Asynchronous JavaScript and JSON (Ajaj) today
• Asynchronously call server endpoints
• You can
o Maintain state in the client side
o Go to the server asynchronously
o Render elements without full page refresh using JavaScript
JavaScript
Libraries/Frameworks
Any application that can be
written in
JavaScript, will eventually
be written in JavaScript
Atwood's Law
REST
• REpresntational State Transfer
• Architecture style for working with HTTP
• Using HTTP verbs (POST, GET, PUT, DELETE)
o Performs Create, Read, Update and Delete operations respectively
o Can also use other HTTP verbs
• Can receive and send data in variety of formats
o JSON, XML, HTML, XHTML, Blob and more
Web API
• The server is used mostly as API
o Each API function is an endpoint
• No need for server page rendering
• No need for server routing
Client-Side Routing
• All routing is performed in the client-side
• You use a routing library/framework
o Or your own implementation on top of HTML5 History API
• When a route changes
o The library/framework intercepts the navigation and performs your
functionality
DEMO
OurCompany SPA
Let’s Get started
Server Side
Demo
File -> New Project -> ASP.NET with MVC and Web API
ASP.NET MVC 101
Controller
(Input)
Model
(Logic)
View
(Presentation)
ASP.NET MVC Players
• Model
o Responsible to hold data
o Sometimes include constraints such as validation
• View
o Responsible to render the view into HTML
o Uses the Razor view engine
• Controller
o Responsible for handling user requests
o User request is mapped to an action on the controller
How Does MVC Work?
Request
View
Controller
Response
Controller
Handles input
(HTTP requests)
View
Visually represents
the model
Demo
MVC in Action
ASP.NET Web API 101
• Web API is designed to leverage the HTTP protocol
• Uses Convention over configuration for actions
o URI + Verb = Controller + Action
• Includes a lot of HTTP concepts built-in
o For example content negotiation or HTTP caching
Demo
Web API in Action
ASP.NET Routing
• Routing is built into ASP.NET
o Can be used by MVC and Web API
• Maps the physical files to logical URLs
• Provides meaningful URLs
• Readable for
o Search engines
o End users
Demo
ASP.NET Routing
How Does ASP.NET Fit
for SPAs?
• ASP.NET MVC acts
o As the single page generator
o As templates generator
o Can help to leverage server side mechanisms when they are needed
• ASP.NET Web API acts
o As the gateway to handle server operations
o As the application API
Front-End
AngularJS?
• A MVW framework
• Developed and supported by Google
• Open source
• No external dependencies
• Very opinionated
Demo
Adding AngularJS to Our Project
AngularJS Building
Blocks
Module
Module
Module
Scope Controller ServiceTemplate
Filter Directive
Two-
Way
Binding
Dependency
Injection
Routing
Controllers
Module
Module
Module
Scope Controller ServiceTemplate
Filter Directive
Dependency
Injection
Routing
Controllers
• The logic behind a view part
• Holds a child scope
o Used as a view-model
• Orchestrators for
o View operations through the scope
o Services
Scopes
• The glue between a controller and a view
• Include properties and the functions set by
controllers that a view can later use
var myApp = angular.module(‘myApp’,[]);
myApp.controller(‘MyController‘, function($scope) {
$scope.message = ‘hello’;
$scope.myFunc = function() {
// do something
}
});
Demo
Controllers
Services
Module
Module
Module
Scope Controller ServiceTemplate
Filter Directive
Dependency
Injection
Routing
Services
• Singleton objects that are used to perform a
specific task
• UI independent
o Shouldn’t manipulate UI elements
• Has different types
o Each type has its own purpose
SERVICE TYPE DESCRIPTION
value The injector will return the exact value
factory The injector will invoke the given factory function
service
The injector will use the new keyword to create the
service single instance
provider The injector will invoke the provider’s $get function
Services – Cont.
• Service declaration example:
var myApp = angular.module(‘myApp’,[]);
myApp.value(‘myValue’, ‘a constant value);
myApp.factory(‘myFactory’, function(name) {
return ‘Hi ‘ + name;
}
Built-in Services
• AngularJS comes with several built-in services
• You can use services such as:
o $http – for communicating over HTTP with remote servers
o $resource – for communicating with REST services
o $q – for creation of promises
o $log – for logging
o $window – for communicating with the window object
o Many more
Demo
Services
Directives
Module
Module
Module
Scope Controller ServiceTemplate
Filter Directive
Dependency
Injection
Routing
Directives
• Custom HTML elements and attributes that
AngularJS recognizes as part of its ecosystem
• Allow to
o Extend the existing HTML with your own elements or attributes
o Add behavior to existing elements or attributes
• Angular includes a long list of built-in directives such
as:
o ng-app – to declare the main module
o ng-controller – to bind a piece of HTML to a controller
o ng-repeat – for collection iterator
o ng-eventName – add custom behavior on a specific event
o Many more
Custom Directives
• You can create your own custom directives
• Use the module directive function and return a
Directive Definition Object (DDO)
• DDOs include various configuration options:
o templateUrl – the URL for a template the directive will use
o Template – appends a given HTML as the child element of the element
o replace – If set to true will replace the entire element with a given
template (used with the template or templateUrl)
o scope – the scope object to use with the directive
o Many more
Custom Directives – Cont.
• Custom directive example:
myApp.directive('myDialog',function () {
return {
restrict: ‘E’,
scope: {},
template: ‘<div>{{message}}</div>’,
link: function(scope, element, attrs) {
scope.message = ‘hello’;
}
};
});
Demo
Directives
Routing
Module
Module
Module
Scope Controller ServiceTemplate
Filter Directive
Dependency
Injection
Routing
Routing
• One of the most important mechanisms in SPAs
• Enables developers to intercept route changes
• Later on, helps to replace a shell element with a
rendered document fragment
• You can use an AngularJS routing module
o For example, ngRoute is a router module for AngularJS
Demo
Full Example Explained
Questions?
Summary
• SPAs are entire web applications built upon one
page and JavaScript interactions
• Very suitable for mobile development
• SPAs are one of the ways to build your next web
apps!
Resources
• Download the slide deck -
• My Blog – http://www.gilfink.net
• Follow me on Twitter – @gilfink
Thank You!
Feedback
http://tiny.cc/hybgyx

More Related Content

What's hot

React or Angular and SharePoint Framework Development
React or Angular and SharePoint Framework DevelopmentReact or Angular and SharePoint Framework Development
React or Angular and SharePoint Framework DevelopmentDarin Dickey
 
Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Alexandre Malavasi
 
Building rest services using aspnetwebapi
Building rest services using aspnetwebapiBuilding rest services using aspnetwebapi
Building rest services using aspnetwebapiBrij Mishra
 
Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017AmarInfotech
 
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?MarkupBox
 
Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Nir Kaufman
 
Build fast word press site in react in 30 mins with frontity
Build fast word press site in react in 30 mins   with frontityBuild fast word press site in react in 30 mins   with frontity
Build fast word press site in react in 30 mins with frontityImran Sayed
 
Interoperability of components built with different frameworks
Interoperability of components built with different frameworksInteroperability of components built with different frameworks
Interoperability of components built with different frameworksSouvik Basu
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSM R Rony
 
Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5Brij Mishra
 
Introduction to Vue.js DevStaff Meetup 13.02
Introduction to Vue.js  DevStaff Meetup 13.02Introduction to Vue.js  DevStaff Meetup 13.02
Introduction to Vue.js DevStaff Meetup 13.02Paul Bele
 
JS Framework Comparison - An infographic
JS Framework Comparison - An infographicJS Framework Comparison - An infographic
JS Framework Comparison - An infographicInApp
 
Moving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMSMoving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMSMake & Build
 
Lessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMLessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMValeri Karpov
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceDomingo Suarez Torres
 

What's hot (20)

Jquery
JqueryJquery
Jquery
 
AngularJS Scopes
AngularJS ScopesAngularJS Scopes
AngularJS Scopes
 
React or Angular and SharePoint Framework Development
React or Angular and SharePoint Framework DevelopmentReact or Angular and SharePoint Framework Development
React or Angular and SharePoint Framework Development
 
Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3Modern Applications With Asp.net Core 5 and Vue JS 3
Modern Applications With Asp.net Core 5 and Vue JS 3
 
Building rest services using aspnetwebapi
Building rest services using aspnetwebapiBuilding rest services using aspnetwebapi
Building rest services using aspnetwebapi
 
Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017Latest Javascript MVC & Front End Frameworks 2017
Latest Javascript MVC & Front End Frameworks 2017
 
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
AngularJS vs React JS vs Node JS: Which is Best For Web Development ?
 
Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs
 
Build fast word press site in react in 30 mins with frontity
Build fast word press site in react in 30 mins   with frontityBuild fast word press site in react in 30 mins   with frontity
Build fast word press site in react in 30 mins with frontity
 
Interoperability of components built with different frameworks
Interoperability of components built with different frameworksInteroperability of components built with different frameworks
Interoperability of components built with different frameworks
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5Building Modern Web Applications with ASP.NET5
Building Modern Web Applications with ASP.NET5
 
Introduction to Vue.js DevStaff Meetup 13.02
Introduction to Vue.js  DevStaff Meetup 13.02Introduction to Vue.js  DevStaff Meetup 13.02
Introduction to Vue.js DevStaff Meetup 13.02
 
JS Framework Comparison - An infographic
JS Framework Comparison - An infographicJS Framework Comparison - An infographic
JS Framework Comparison - An infographic
 
ASP.NET MVC 4
ASP.NET MVC 4ASP.NET MVC 4
ASP.NET MVC 4
 
Moving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMSMoving from PHP to a nodejs full stack CMS
Moving from PHP to a nodejs full stack CMS
 
MEAN Stack
MEAN Stack MEAN Stack
MEAN Stack
 
From zero to hero with Docker
From zero to hero with DockerFrom zero to hero with Docker
From zero to hero with Docker
 
Lessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODMLessons in Open Source from the MongooseJS ODM
Lessons in Open Source from the MongooseJS ODM
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page Interface
 

Similar to End to-End SPA Development Using ASP.NET and AngularJS

Similar to End to-End SPA Development Using ASP.NET and AngularJS (20)

Angular js
Angular jsAngular js
Angular js
 
Angular js
Angular jsAngular js
Angular js
 
Angular patterns
Angular patternsAngular patterns
Angular patterns
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Angular
AngularAngular
Angular
 
AngularJs Basic Concept
AngularJs Basic ConceptAngularJs Basic Concept
AngularJs Basic Concept
 
Introduction to AngularJs
Introduction to AngularJsIntroduction to AngularJs
Introduction to AngularJs
 
Fast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVCFast Track introduction to ASP.NET MVC
Fast Track introduction to ASP.NET MVC
 
AngularJS One Day Workshop
AngularJS One Day WorkshopAngularJS One Day Workshop
AngularJS One Day Workshop
 
AngularJS
AngularJSAngularJS
AngularJS
 
Mvc
MvcMvc
Mvc
 
Angularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetupAngularjs for kolkata drupal meetup
Angularjs for kolkata drupal meetup
 
Angular js 1.0-fundamentals
Angular js 1.0-fundamentalsAngular js 1.0-fundamentals
Angular js 1.0-fundamentals
 
Angularjs basic part01
Angularjs basic part01Angularjs basic part01
Angularjs basic part01
 
Angularjs
AngularjsAngularjs
Angularjs
 
Spa with angular
Spa with angularSpa with angular
Spa with angular
 
Webinar MVC6
Webinar MVC6Webinar MVC6
Webinar MVC6
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 

More from Gil Fink

Becoming a Tech Speaker
Becoming a Tech SpeakerBecoming a Tech Speaker
Becoming a Tech SpeakerGil Fink
 
Web animation on steroids web animation api
Web animation on steroids web animation api Web animation on steroids web animation api
Web animation on steroids web animation api Gil Fink
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedGil Fink
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedGil Fink
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedGil Fink
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedGil Fink
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedGil Fink
 
Being a tech speaker
Being a tech speakerBeing a tech speaker
Being a tech speakerGil Fink
 
Working with Data in Service Workers
Working with Data in Service WorkersWorking with Data in Service Workers
Working with Data in Service WorkersGil Fink
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular AnimationsGil Fink
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angularGil Fink
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angularGil Fink
 
Who's afraid of front end databases?
Who's afraid of front end databases?Who's afraid of front end databases?
Who's afraid of front end databases?Gil Fink
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type scriptGil Fink
 
End to-end apps with type script
End to-end apps with type scriptEnd to-end apps with type script
End to-end apps with type scriptGil Fink
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven developmentGil Fink
 
Web components
Web componentsWeb components
Web componentsGil Fink
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2Gil Fink
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSGil Fink
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databasesGil Fink
 

More from Gil Fink (20)

Becoming a Tech Speaker
Becoming a Tech SpeakerBecoming a Tech Speaker
Becoming a Tech Speaker
 
Web animation on steroids web animation api
Web animation on steroids web animation api Web animation on steroids web animation api
Web animation on steroids web animation api
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has Arrived
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Being a tech speaker
Being a tech speakerBeing a tech speaker
Being a tech speaker
 
Working with Data in Service Workers
Working with Data in Service WorkersWorking with Data in Service Workers
Working with Data in Service Workers
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular Animations
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
 
Who's afraid of front end databases?
Who's afraid of front end databases?Who's afraid of front end databases?
Who's afraid of front end databases?
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type script
 
End to-end apps with type script
End to-end apps with type scriptEnd to-end apps with type script
End to-end apps with type script
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Web components
Web componentsWeb components
Web components
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJS
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
 

Recently uploaded

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

End to-End SPA Development Using ASP.NET and AngularJS

  • 1. End-to-End SPA Development using ASP.NET and AngularJS Gil Fink CEO and Senior Consultant, sparXys
  • 3. Managers and SPA Trying to solve the puzzle of single page application…
  • 4. Even the Shortened Name is Misleading… Let’s build a SPA?
  • 5. About Me • sparXys CEO and Senior consultant • ASP.NET/IIS Microsoft MVP • Co-author of Pro Single Page Application Development (Apress) • Co-author of 4 Microsoft Official Courses (MOCs) • Co-organizer of GDG Rashlatz
  • 6. Agenda • The Road to Single Page Applications • What is a SPA? • SPA Building Blocks • ASP.NET MVC/Web API in the Backend • AngularJS in the Front-End
  • 7. The Road to SPAs 1990 HTML HTTP 1995 Java Applets 1996 CSS JavaScript Flash 1997 HTML 4 2005 Ajax is a buzzword 2006 work on HTML5 starts 2007 Silverlight Mobile Web
  • 8. Traditional Websites OMG! not this kind of traditional website please!
  • 9. Traditional Native Apps Native apps – we love installation experience… Not!
  • 10. What is a SPA? Web Application No full page submit No full page refresh No embedded objects (plugins) Client-side templating and routing
  • 11. Why to Develop SPAs? Feature Web App Native App Single Page App Cross Platform functionality V X V Client State Management X V V No Installation required V X V Web App Native App SPA
  • 12. SPA Building Blocks HTML5 JavaScript Libraries Ajax REST SPA Web API Routing
  • 13. HTML5 • Supported by most modern browsers o www.caniuse.com • Includes new JavaScript APIs that can help to: o Store data locally o Persist data across application shutdowns o Communicate with the server in new ways o Increase web performance with new specifications and APIs
  • 14. Ajax • Asynchronous JavaScript and XML o No XML these days… o Asynchronous JavaScript and JSON (Ajaj) today • Asynchronously call server endpoints • You can o Maintain state in the client side o Go to the server asynchronously o Render elements without full page refresh using JavaScript
  • 16. Any application that can be written in JavaScript, will eventually be written in JavaScript Atwood's Law
  • 17. REST • REpresntational State Transfer • Architecture style for working with HTTP • Using HTTP verbs (POST, GET, PUT, DELETE) o Performs Create, Read, Update and Delete operations respectively o Can also use other HTTP verbs • Can receive and send data in variety of formats o JSON, XML, HTML, XHTML, Blob and more
  • 18. Web API • The server is used mostly as API o Each API function is an endpoint • No need for server page rendering • No need for server routing
  • 19. Client-Side Routing • All routing is performed in the client-side • You use a routing library/framework o Or your own implementation on top of HTML5 History API • When a route changes o The library/framework intercepts the navigation and performs your functionality
  • 23.
  • 24. Demo File -> New Project -> ASP.NET with MVC and Web API
  • 26. ASP.NET MVC Players • Model o Responsible to hold data o Sometimes include constraints such as validation • View o Responsible to render the view into HTML o Uses the Razor view engine • Controller o Responsible for handling user requests o User request is mapped to an action on the controller
  • 27. How Does MVC Work? Request View Controller Response Controller Handles input (HTTP requests) View Visually represents the model
  • 29. ASP.NET Web API 101 • Web API is designed to leverage the HTTP protocol • Uses Convention over configuration for actions o URI + Verb = Controller + Action • Includes a lot of HTTP concepts built-in o For example content negotiation or HTTP caching
  • 30. Demo Web API in Action
  • 31. ASP.NET Routing • Routing is built into ASP.NET o Can be used by MVC and Web API • Maps the physical files to logical URLs • Provides meaningful URLs • Readable for o Search engines o End users
  • 33. How Does ASP.NET Fit for SPAs? • ASP.NET MVC acts o As the single page generator o As templates generator o Can help to leverage server side mechanisms when they are needed • ASP.NET Web API acts o As the gateway to handle server operations o As the application API
  • 35.
  • 36. AngularJS? • A MVW framework • Developed and supported by Google • Open source • No external dependencies • Very opinionated
  • 38. AngularJS Building Blocks Module Module Module Scope Controller ServiceTemplate Filter Directive Two- Way Binding Dependency Injection Routing
  • 40. Controllers • The logic behind a view part • Holds a child scope o Used as a view-model • Orchestrators for o View operations through the scope o Services
  • 41. Scopes • The glue between a controller and a view • Include properties and the functions set by controllers that a view can later use var myApp = angular.module(‘myApp’,[]); myApp.controller(‘MyController‘, function($scope) { $scope.message = ‘hello’; $scope.myFunc = function() { // do something } });
  • 44. Services • Singleton objects that are used to perform a specific task • UI independent o Shouldn’t manipulate UI elements • Has different types o Each type has its own purpose SERVICE TYPE DESCRIPTION value The injector will return the exact value factory The injector will invoke the given factory function service The injector will use the new keyword to create the service single instance provider The injector will invoke the provider’s $get function
  • 45. Services – Cont. • Service declaration example: var myApp = angular.module(‘myApp’,[]); myApp.value(‘myValue’, ‘a constant value); myApp.factory(‘myFactory’, function(name) { return ‘Hi ‘ + name; }
  • 46. Built-in Services • AngularJS comes with several built-in services • You can use services such as: o $http – for communicating over HTTP with remote servers o $resource – for communicating with REST services o $q – for creation of promises o $log – for logging o $window – for communicating with the window object o Many more
  • 49. Directives • Custom HTML elements and attributes that AngularJS recognizes as part of its ecosystem • Allow to o Extend the existing HTML with your own elements or attributes o Add behavior to existing elements or attributes • Angular includes a long list of built-in directives such as: o ng-app – to declare the main module o ng-controller – to bind a piece of HTML to a controller o ng-repeat – for collection iterator o ng-eventName – add custom behavior on a specific event o Many more
  • 50. Custom Directives • You can create your own custom directives • Use the module directive function and return a Directive Definition Object (DDO) • DDOs include various configuration options: o templateUrl – the URL for a template the directive will use o Template – appends a given HTML as the child element of the element o replace – If set to true will replace the entire element with a given template (used with the template or templateUrl) o scope – the scope object to use with the directive o Many more
  • 51. Custom Directives – Cont. • Custom directive example: myApp.directive('myDialog',function () { return { restrict: ‘E’, scope: {}, template: ‘<div>{{message}}</div>’, link: function(scope, element, attrs) { scope.message = ‘hello’; } }; });
  • 54. Routing • One of the most important mechanisms in SPAs • Enables developers to intercept route changes • Later on, helps to replace a shell element with a rendered document fragment • You can use an AngularJS routing module o For example, ngRoute is a router module for AngularJS
  • 57. Summary • SPAs are entire web applications built upon one page and JavaScript interactions • Very suitable for mobile development • SPAs are one of the ways to build your next web apps!
  • 58. Resources • Download the slide deck - • My Blog – http://www.gilfink.net • Follow me on Twitter – @gilfink