Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему Net framework: developing modern web apps with asp.net mvc

Содержание

How to View This PresentationSwitch to Notes Page view:Click View on the ribbon and select Notes PageUse page up or page down to navigateZoom in or out as neededIn the Notes Page view you can:Read any
< Engineer Name >Premier Field Engineer.NET Framework: Developing Modern Web Apps with ASP.NET MVC WorkshopPlus How to View This PresentationSwitch to Notes Page view:Click View on the Module 6: Client-Side DevelopmentModule OverviewMVC 6 support for client-side developmentClient-side files in Module 6: Client-Side DevelopmentSection 1: SupportLesson: MVC and JavaScript Why using JavaScript in ASP.NET MVC?Combining server-side and client-side processing.More responsive web Project Template – wwwroot folderAll static files should be located in this Project Template – JavaScript Libraries Part 1_references.jsContains JavaScript reference in the form Project Template – JavaScript Libraries Part 2Bootstrap-touch-carousel & hammer.jsA slideshow component for Project Template – JavaScript Libraries Part 3Jquery-version.intellisense.jsExtending IntelliSense for jQuery libraryJquery-version.js and Client-Side Development Configuration Filesgulpfile.jsJavascript Configuration of Gulp tasksProject.jsonMain project file. NuGet package Module 6: Client-Side DevelopmentSection 1: Support Lesson: Bower and Gulp Why using Gulp (or Grunt) and Bower?Modern web applications incorporate various and What is Bower?“A package manager for the web” (http://bower.io)Installs and restores client-side What is Gulp?“The JavaScript Task Runner” (http://gulpjs.com)An application to automates routine client-side Bundling and MinificationBundling reduces the number of requests to the server Combining Demo: Bower and Gulp Module 6: Client-Side DevelopmentSection 2: TechniquesLesson: Styling with Bootstrap Intro to Bootstrap Why use it?CSS is can be trickyCross browser support can be a Browser SupportSupport the latest version of browsers on the following systems: Bootstrap FeaturesTheme Support ResponsiveGridComponentsPaginationButtonsModalGreat Visual Studio support Theme Support (Default) Easy Theme Support (Custom) Responsive Layout Responsive Layout Grid System Grid System ComponentsReusable components built to provide navigation, alerts, progress bars, pagination and many more. Visual Studio – Class Intellisense Visual Studio – Missing Class Detection Module 6: Client-Side DevelopmentSection 2: TechniquesLesson: JavaScript and jQuery Using JavaScript in MVC 6JavaScript scripts can be defined inside a View jQuery and MicrosoftLightweight open source JavaScript libraryDeprecated Microsoft.Ajax libraries in favor of jQueryReduces client-side codingCSS 3-based syntax for traversing and manipulating DOMConcise wrappers for jQuery: SelectorsExecute commands on a single or multiple selected DOM elements.Basic types jQuery: Selectors (continue)Specific operators are used to expand selection optionsA white space jQuery: FiltersUsed with Selectors, or alonePositional filters :first, :even, :eq(index), :gt(index), :not jQuery: MethodsClass/Style MethodsUse to apply CSS styles to the result of a jQuery: EventsjQuery simplifies events implementationEvents are triggered by the page or end Unobtrusive JavaScriptTraditonal use of JavaScriptFor cleaner HTML page, remove inline JavaScript references.jQuery Module 6: Client-Side DevelopmentSection 2: TechniquesLesson: AJAX Ajax - (Asynchronous JavaScript and XML)Send and receive data from a server AJAX EngineJavascript Engine(eg Chakra)Controller Action MethodUser Interactions / EventsGUI - HTML Document AJAX in JquerySimplifies AJAX implementation in JavaScript.The full-feature .ajax() method Perform an MVC’s AJAX HelpersMethods providing and simplifying client-side functionality implementation in MVC.Asynchronous forms Ajax in Actions – Get RequestEither enable Get requests in code like this: Ajax in ActionsOr create a new ActionMethodSelectorAttribute Module 6: Client-Side DevelopmentSection 3: Single Page ApplicationLesson: Fundamentals Single Page Application (SPA)In traditional web application, the server responds to new SPA - DesignModel View View Model (MVVM) modelVariance of MVCView faces the MVVM in generalMain point in MVVM is the binding of data in MVVM advantagesProvides same separation benefits as MVC patternSeparation of responsibilities between development MVVM disadvantagesData-bindings are harder to debugViewModel can be hard to design up Bringing MVVM to ASP.NET MVCYou don’t need to have multiple views per How it worksSQLRepositories & ModelController (Web API)View Model (JS)View (Razor)Styling (CSS)Client side JavaScriptWeb ApplicationOther WCFServicesControllerUserWCF Services Using 3rd party MVVM-librariesThere is no point in building scripts required for KnockoutJS example: Model to View      First name: KnockoutJS example: View to Model      First name: AngularJS example: Model to View      First name: MV* frameworkFor Single Page Application  You need only one script file: Data binding, as in {{}}DOM control structures for repeating/hiding DOM fragmentsSupport for Concepts What is a Controller?Controllers Controllersindex.htmlcardsController.js What shouldn’t a controller do?Controllers Open CA.1Implement the cardsListControllerIt should set $scope.cards to an array of JS What is a Module?You can think of a module as a container Modulesangular.js Modulesangular.js Modulesangular.js What is Dependency Injection?Dependency Injection create the dependency, typically using the new operator.look up the dependency, by How does the injector locate dependencies?Dependency Injection Implicit locationDependency InjectionAssume the parameter names are names of servicesQ: Problems with this method? Property AnnotationDependency InjectionThe $inject property is an array of services to inject.Q: Thoughts? Inline Array AnnotationDependency InjectionDefine services inline when creating the controller.Q: Thoughts? Open CA. 2In cardsController.js, create a cardsController module. Add cardsListController to it.In $http$resourcesFiltersGetting dataangular.jsangular-resource.js What is a promise?Promises Filters Hands On Lab: Build a Single Page Application (SPA) with ASP.NET Web API and Angular.jsLab Work Open CA.3Modify cardsListController to read the data from all.json.Push each card from angular-animate.js SPA uses views to build UIAngular.js uses routing to define viewsAnimationsRouting and viewsangular-route.jsangular.jsangular-resource.js ngViewRoutingangular-route.jsangular.jsModule ComponentsA directive that complements the $route service. It includes the rendered Route ProviderRoutingangular-route.jsangular.jsModule Components$routeProvider is used for configuring routes.config.route.js Route ServiceRoutingangular-route.jsangular.jsModule Components$route is used for deep-linking URLs to controllers and views.controller.jstemplate.html Route ParametersRoutingangular-route.jsangular.jsModule Components$routeParams allows you to retrieve the current set of route parameters.controller.detail.js HTML from view – no problem!HTML file – use an IIS Rewrite Open CA.4Add a filter to app.js called filterAndReduce. Look at index.html to Open CA.5Create a route that responds to the URI /cards and displays Productivity Toolshttp://www.sidewaffle.com Productivity ToolsBatarang – Chrome Extensionhttps://github.com/angular/angularjs-batarang Module 6: Client-Side DevelopmentSection 1: Development ToolsLesson: Tools jQuery – Tools / F12 jQuery – in Visual StudioPage Inspector Module SummaryMVC 6 support for client-side through default project templateBootstrap for UI Lab: Client-Side Development
Слайды презентации

Слайд 2


Слайд 3 How to View This Presentation
Switch to Notes Page

How to View This PresentationSwitch to Notes Page view:Click View on

view:
Click View on the ribbon and select Notes Page
Use

page up or page down to navigate
Zoom in or out as needed
In the Notes Page view you can:
Read any supporting text, now or after the delivery
Add your own notes
Take the presentation files home with you


Слайд 4 Module 6: Client-Side Development
Module Overview
MVC 6 support for

Module 6: Client-Side DevelopmentModule OverviewMVC 6 support for client-side developmentClient-side files

client-side development
Client-side files in MVC 6 project templates
Bower, Gulpjs/Gruntjs
Introduction

to Bootstrap
Primer on JavaScript, Jquery and AJAX
Single Page Application explained (knockoutjs/angularjs)
Lesson name
Lab

Слайд 5 Module 6: Client-Side Development
Section 1: Support
Lesson: MVC and

Module 6: Client-Side DevelopmentSection 1: SupportLesson: MVC and JavaScript

JavaScript


Слайд 6 Why using JavaScript in ASP.NET MVC?
Combining server-side and

Why using JavaScript in ASP.NET MVC?Combining server-side and client-side processing.More responsive

client-side processing.
More responsive web applications.
JavaScript comes in many forms:
AJAX

– Partial page update and refresh
Jquery – Elegantly and Efficiently find and manipulate HTML DOM elements
MooTools – Modular JavaScript and code reuse
Prototype – Simplify development of dynamic web application
Node.js – Developing high performance JavaScript via multithreading model
Industry standard for modern web development
And many more


Слайд 7 Project Template – wwwroot folder
All static files should

Project Template – wwwroot folderAll static files should be located in

be located in this folder (JavaScripts, CSS, images or

HTML files)
wwwroot folder is the root of the website
http://hostname/ points to wwwroot
All static content should be relative to the folder
Code files should be places outside of wwwroot (C# or Razor).
Static files created through compilation or pre-processing should be copied into wwwroot.
Can be renamed by changing “webroot” setting in the project.json file.


Слайд 8 Project Template – JavaScript Libraries Part 1
_references.js
Contains JavaScript

Project Template – JavaScript Libraries Part 1_references.jsContains JavaScript reference in the

reference in the form of comments
Allows Visual Studio to

augment IntelliSense support for JavaScript
The autosync flag set to true:
JavaScript files are automatically be added.
Automatic update when a referenced file is moved.
Manual update is possible via right clicking on the file.
Bootstrap.js and bootstrap.min.js
HTML, CSS and JavaScript-based design templates for creating responsive web sites.
Note! Always use the .min version of a JavaScript file to improve load time.


Слайд 9 Project Template – JavaScript Libraries Part 2
Bootstrap-touch-carousel &

Project Template – JavaScript Libraries Part 2Bootstrap-touch-carousel & hammer.jsA slideshow component

hammer.js
A slideshow component for cycling through elements, like a

carousel.
Enable gestures on touch devices using hammer.js, a javascript library for multi-touch gestures.

Слайд 10 Project Template – JavaScript Libraries Part 3
Jquery-version.intellisense.js
Extending IntelliSense

Project Template – JavaScript Libraries Part 3Jquery-version.intellisense.jsExtending IntelliSense for jQuery libraryJquery-version.js

for jQuery library
Jquery-version.js and jquery-version.min.js
Main JQuery version
Jquery-version.min.map
Allows to map

to the un-minified version of JQuery for troubleshooting purposes.
Jquery.validate.js (Jquery.validate.min.js)
Provide client side validation using jQuery
Multilanguage support
Jquery.validate.unobtrusive.js and jquery.validate.unobtrusive.min.js


Слайд 11 Client-Side Development Configuration Files
gulpfile.js
Javascript Configuration of Gulp tasks
Project.json
Main

Client-Side Development Configuration Filesgulpfile.jsJavascript Configuration of Gulp tasksProject.jsonMain project file. NuGet

project file. NuGet package dependencies are listed here
Package.json
Lists npm

packages
Bower.json
Lists Bower packages


Слайд 12 Module 6: Client-Side Development
Section 1: Support
Lesson: Bower

Module 6: Client-Side DevelopmentSection 1: Support Lesson: Bower and Gulp

and Gulp


Слайд 13 Why using Gulp (or Grunt) and Bower?
Modern web

Why using Gulp (or Grunt) and Bower?Modern web applications incorporate various

applications incorporate various and rich client-side libraries such as

jQuery, TypeScript, Bootstrap etc.
Easy management of client-side packages
Automating build tasks such as scripts compilation, bundling, minification or unit testing.
Leverage existing tools from the web development community.


Слайд 14 What is Bower?
“A package manager for the web”

What is Bower?“A package manager for the web” (http://bower.io)Installs and restores

(http://bower.io)
Installs and restores client-side libraries.
Keeps track of all the

packages in a manifest file, bower.json
Improves page load.


Слайд 15 What is Gulp?
“The JavaScript Task Runner” (http://gulpjs.com)
An application

What is Gulp?“The JavaScript Task Runner” (http://gulpjs.com)An application to automates routine

to automates routine client-side development tasks (compilation, bundling, minification,

unit testing etc…)
gulpfile.js contains Gulp tasks with JavaScript-like configuration
Grunt is another task runner.
Gulpfile.js uses JSON-like syntax for configuration


Слайд 16 Bundling and Minification
Bundling reduces the number of requests

Bundling and MinificationBundling reduces the number of requests to the server

to the server
Combining multiple files into a single

file.
Create CSS, JavaScript and other bundles.
Use the “Include” or “IncludeDirectory” of the Bundle Class
Minification reduces the size of the requested assets (CSS and JavaScript).
MVC 6 uses Gulp or Grunt to achieve bundling and minification.


Слайд 17 Demo: Bower and Gulp

Demo: Bower and Gulp

Слайд 18 Module 6: Client-Side Development
Section 2: Techniques
Lesson: Styling with

Module 6: Client-Side DevelopmentSection 2: TechniquesLesson: Styling with Bootstrap

Bootstrap


Слайд 19 Intro to Bootstrap

Intro to Bootstrap

Слайд 20 Why use it?
CSS is can be tricky
Cross browser

Why use it?CSS is can be trickyCross browser support can be

support can be a challenge
Solves basic tasks (e.g. page

layout without tables)
Bootstrap 3 makes it easier


Слайд 21 Browser Support
Support the latest version of browsers on

Browser SupportSupport the latest version of browsers on the following systems:

the following systems:


Слайд 22 Bootstrap Features
Theme Support
Responsive
Grid
Components
Pagination
Buttons
Modal
Great Visual Studio support

Bootstrap FeaturesTheme Support ResponsiveGridComponentsPaginationButtonsModalGreat Visual Studio support

Слайд 23 Theme Support (Default)

Theme Support (Default)

Слайд 24 Easy Theme Support (Custom)

Easy Theme Support (Custom)

Слайд 25 Responsive Layout

Responsive Layout

Слайд 26 Responsive Layout

Responsive Layout

Слайд 27 Grid System

Grid System

Слайд 28 Grid System

Grid System

Слайд 29 Components
Reusable components built to provide navigation, alerts, progress

ComponentsReusable components built to provide navigation, alerts, progress bars, pagination and many more.

bars, pagination and many more.


Слайд 30 Visual Studio – Class Intellisense

Visual Studio – Class Intellisense

Слайд 31 Visual Studio – Missing Class Detection

Visual Studio – Missing Class Detection

Слайд 32 Module 6: Client-Side Development
Section 2: Techniques
Lesson: JavaScript and

Module 6: Client-Side DevelopmentSection 2: TechniquesLesson: JavaScript and jQuery

jQuery


Слайд 33 Using JavaScript in MVC 6
JavaScript scripts can be

Using JavaScript in MVC 6JavaScript scripts can be defined inside a

defined inside a View using the html script tag

like in a html page.
Use the MVC @section tag to organize JavaScript scripts
The @RenderSection is used to inject JavaScript at a desired location inside the View.
For best practices, declare JavaScript scripts inside a .js file.
Use a minification tool in Visual Studio for optimization.
IntelliSence support for JavaScript in Visual Studio


Слайд 34 jQuery and Microsoft
Lightweight open source JavaScript library
Deprecated Microsoft.Ajax

jQuery and MicrosoftLightweight open source JavaScript libraryDeprecated Microsoft.Ajax libraries in favor

libraries in favor of jQuery.
Distributed jQuery library with Visual

Studio projects since 2008.
Extended Microsoft product support for jQuery
Enterprises can open jQuery support cases 24x7 with Microsoft Support.
Integrated Client template support
Default templates leverage jQuery


Слайд 35 jQuery
Reduces client-side coding
CSS 3-based syntax for traversing and

jQueryReduces client-side codingCSS 3-based syntax for traversing and manipulating DOMConcise wrappers

manipulating DOM
Concise wrappers for Ajax calls
Abstracted to eliminate cross-browser

differences
Unobtrusive client validation
XPath selectors to access elements in the DOM
Elements are retrieved in the form of jQuery objects
Start with jquery(), jquery., $() or $. to use jQuery


Слайд 36 jQuery: Selectors
Execute commands on a single or multiple

jQuery: SelectorsExecute commands on a single or multiple selected DOM elements.Basic

selected DOM elements.
Basic types of selectors:
Based on HTML elements

IDs e.g.: $(“#main”)
Based on cascading style sheets (CSS) e.g.: $(“.header”)
Based on element tags e.g.: $(“div”)
Based on element attributes e.g.: $(“[type = ‘button’]”)
Build more complex selectors through combination
$(“#main p.quote”) ⬄ Select paragraphs with a “quote” CSS class located inside elements with IDs equal to “main”
$(this) operator

Слайд 37 jQuery: Selectors (continue)
Specific operators are used to expand

jQuery: Selectors (continue)Specific operators are used to expand selection optionsA white

selection options
A white space selects all elements that are

descendants of the given ancestor e.g.: $(“div p”) ⬄ $(“div”).find(“p”)
The > operator selects direct child elements of the given ancestor e.g.: $(“div > p”) ⬄ $(“div”).children(“p”)
The + operator selects adjacent elements
e.g.: $(“div + p”) ⬄ $(“div”).next(“p”)
The ~ operator selects all siblings elements
e.g.: $(“div ~ p”) ⬄ $(“div”).nextall(“p”)
The comma operator selects all the specified elements
e.g: $(div, p, a)


Слайд 38 jQuery: Filters
Used with Selectors, or alone
Positional filters :first,

jQuery: FiltersUsed with Selectors, or alonePositional filters :first, :even, :eq(index), :gt(index),

:even, :eq(index), :gt(index), :not (selector) etc.
Child filters :nth-child(expression),

:first-child, :only-child
Content filters :contains(text), has(selector), :parent, :empty
Form filter :visible, :hidden, :button, :input, :selected
Can be chained by appending with colon (:) for example:


Слайд 39 jQuery: Methods
Class/Style Methods
Use to apply CSS styles to

jQuery: MethodsClass/Style MethodsUse to apply CSS styles to the result of

the result of a selector
.addClass(), .css(), .height(), .position()
DOM Methods
.before(),

.insertBefore(), .append(), .empty(), .attr()


Слайд 40 jQuery: Events
jQuery simplifies events implementation
Events are triggered by

jQuery: EventsjQuery simplifies events implementationEvents are triggered by the page or

the page or end user’s interaction
Events are often used

to attach a callback function
To bind an event:
Use of function to bind a event directly e.g.: .click()
Use .on() e.g.: .on(“click”, …)
Use .bind() e.g.: .bind(“click”, …)
Use .live() e.g.: .live(“click, …)


Слайд 41 Unobtrusive JavaScript
Traditonal use of JavaScript

Unobtrusive JavaScriptTraditonal use of JavaScriptFor cleaner HTML page, remove inline JavaScript

onclick="handleClick()" />
For cleaner HTML page, remove inline JavaScript references.
jQuery

makes it easy to attach handlers to DOM elements






Слайд 42 Module 6: Client-Side Development
Section 2: Techniques
Lesson: AJAX

Module 6: Client-Side DevelopmentSection 2: TechniquesLesson: AJAX

Слайд 43 Ajax - (Asynchronous JavaScript and XML)
Send and receive

Ajax - (Asynchronous JavaScript and XML)Send and receive data from a

data from a server asynchronously (in the background) –

better performance.
Uses XMLHttpRequest object
JSON typically used instead of XML
Back button and bookmarking challenges
Downgrade challenges for mobile devices that don’t support JavaScript.
Webcrawlers don’t index pages created via Ajax
Does not work across domains by default


Слайд 44 AJAX Engine



Javascript Engine
(eg Chakra)
Controller
Action Method
User Interactions /

AJAX EngineJavascript Engine(eg Chakra)Controller Action MethodUser Interactions / EventsGUI - HTML

Events
GUI - HTML Document Object Model (DOM)
Javascript Updates GUI

JSON


Browser

Server


Слайд 45 AJAX in Jquery
Simplifies AJAX implementation in JavaScript.
The full-feature

AJAX in JquerySimplifies AJAX implementation in JavaScript.The full-feature .ajax() method Perform

.ajax() method Perform an asynchronous HTTP (Ajax) request.
Shortcuts: .get(),

.getScript(), .getJSON(), .post(), .load().
$.ajaxSetup() method specifies settings for an Ajax call.

Слайд 46 MVC’s AJAX Helpers
Methods providing and simplifying client-side functionality

MVC’s AJAX HelpersMethods providing and simplifying client-side functionality implementation in MVC.Asynchronous

implementation in MVC.
Asynchronous forms and rendering links
Methods and extensions

are called using the Ajax property of the view.
Use Request.IsAjaxRequest() for checking Ajax requests


Слайд 47 Ajax in Actions – Get Request
Either enable Get

Ajax in Actions – Get RequestEither enable Get requests in code like this:

requests in code like this:


Слайд 48 Ajax in Actions
Or create a new ActionMethodSelectorAttribute

Ajax in ActionsOr create a new ActionMethodSelectorAttribute

Слайд 49 Module 6: Client-Side Development
Section 3: Single Page Application
Lesson:

Module 6: Client-Side DevelopmentSection 3: Single Page ApplicationLesson: Fundamentals

Fundamentals


Слайд 50 Single Page Application (SPA)
In traditional web application, the

Single Page Application (SPA)In traditional web application, the server responds to

server responds to new page requests.
In SPA, the full

page is loaded at initial request.
Subsequent interactions take place through Ajax requests without full page reload.
Better user experience
Some SPA frameworks
AngularJS
KnockoutJS
Backbone
EmberJS
DurandalJS
Hot Towel


Слайд 51 SPA - Design
Model View View Model (MVVM) model
Variance

SPA - DesignModel View View Model (MVVM) modelVariance of MVCView faces

of MVC
View faces the user
Commands within the ViewModel are

triggered by the View
Changes in the ViewModel cause events that make the View update itself
If a new View is required, the ViewModel communicates this with the application to redirect the user
Model is the same



Слайд 52 MVVM in general
Main point in MVVM is the

MVVM in generalMain point in MVVM is the binding of data

binding of data in the Model automatically to the

View
MVVM is widely used with Silverlight and WPF projects (where data binding is “built-in”
When MVVM is used with ASP.NET, view-model resides in client side (JavaScript)
Best choice for a “modern application”
No postbacks and less page loads
More asynchronous operations that don’t “freeze” the browser
Brings application look and feel to “web pages”


Слайд 53 MVVM advantages
Provides same separation benefits as MVC pattern
Separation

MVVM advantagesProvides same separation benefits as MVC patternSeparation of responsibilities between

of responsibilities between development teams
Separation of concerns between business

logic and presentation
Model is not directly exposed to client like MVC
Works best with
Silverlight and WPF applications
Single-page web applications
Web applications with wizards or processes


Слайд 54 MVVM disadvantages
Data-bindings are harder to debug
ViewModel can be

MVVM disadvantagesData-bindings are harder to debugViewModel can be hard to design

hard to design up front
But while using agile development

methods this shouldn’t be a problem
With Large development teams, ViewModel can be easily “polluted” with duplicated code
Don’t allow everyone in the team to make changes to ViewModel
Data-binding to custom or 3rd party components can be complex or sometimes even impossible


Слайд 55 Bringing MVVM to ASP.NET MVC
You don’t need to

Bringing MVVM to ASP.NET MVCYou don’t need to have multiple views

have multiple views per controller, changing the UI will

be controlled by the ViewModel
One view can have several div-elements and their visibility is controlled by the ViewModel
Think the server side as “initializer” and data provider
After 1st page load is completed, everything happens on client side
Except when UI needs updated data from server and executes and AJAX request
You can use all ASP.NET MVC features the way you have used them before
But you need to code a lot more in JavaScript


Слайд 56 How it works
SQL
Repositories & Model
Controller (Web API)
View Model

How it worksSQLRepositories & ModelController (Web API)View Model (JS)View (Razor)Styling (CSS)Client side JavaScriptWeb ApplicationOther WCFServicesControllerUserWCF Services

(JS)
View (Razor)
Styling (CSS)
Client side JavaScript
Web Application
Other WCF
Services
Controller
User
WCF Services


Слайд 57 Using 3rd party MVVM-libraries
There is no point in

Using 3rd party MVVM-librariesThere is no point in building scripts required

building scripts required for automatic binding from scratch
ASP.NET MVC

6 is fully integrated with 3rd party libraries like:
knockoutJS (http://knckoutjs.com)
angularJS (https://angularjs.org/)
Remember to use Bower and Grunt/Gulp to install 3rd party libraries


Слайд 58 KnockoutJS example: Model to View

KnockoutJS example: Model to View   First name:

First name:

Lirst name:







Model

View
Model


When this gets executed...


Слайд 59 KnockoutJS example: View to Model

KnockoutJS example: View to Model   First name:

First name:

Lirst name:







Model

View
Model


KnockoutJS automatically binds (or ”updates”) the data back
into the model


Слайд 60 AngularJS example: Model to View

AngularJS example: Model to View   First name:

ng-controller="MyController">
First name:

Last name:


{{viewModel.firstName}} {{viewModel.lastName}}







Model

View
Model


Слайд 61 MV* framework
For Single Page Application You need only one

MV* frameworkFor Single Page Application You need only one script file:

script file:

Latest version here:
http://code.angularjs.org/

First contact with Angular.js


Слайд 62 Data binding, as in {{}}
DOM control structures for

Data binding, as in {{}}DOM control structures for repeating/hiding DOM fragmentsSupport

repeating/hiding DOM fragments
Support for forms and form validation
Attaching code-behind

to DOM elements
Grouping of HTML into reusable components

New constructs


Слайд 63 Concepts

Concepts

Слайд 64 What is a Controller?
Controllers

What is a Controller?Controllers

Слайд 65 Controllers
index.html
cardsController.js

Controllersindex.htmlcardsController.js

Слайд 66 What shouldn’t a controller do?
Controllers

What shouldn’t a controller do?Controllers

Слайд 67 Open CA.1
Implement the cardsListController
It should set $scope.cards to

Open CA.1Implement the cardsListControllerIt should set $scope.cards to an array of

an array of JS objects with an id property.

(see index.html)

Magic the Gathering


Слайд 68 What is a Module?
You can think of a

What is a Module?You can think of a module as a

module as a container for the different parts of

your app – controllers, services, filters, directives, etc.

Modules

angular.js


Слайд 69
Modules
angular.js

Modulesangular.js

Слайд 70
Modules
angular.js

Modulesangular.js

Слайд 71
Modules
angular.js

Modulesangular.js

Слайд 72 What is Dependency Injection?
Dependency Injection

What is Dependency Injection?Dependency Injection

Слайд 73 create the dependency, typically using the new operator.
look

create the dependency, typically using the new operator.look up the dependency,

up the dependency, by referring to a global variable.
have

the dependency passed to it where it is needed.

Dependency Injection

How can a component get ahold of it’s dependencies?

It can…


Слайд 74 How does the injector locate dependencies?
Dependency Injection

How does the injector locate dependencies?Dependency Injection

Слайд 75 Implicit location
Dependency Injection
Assume the parameter names are names

Implicit locationDependency InjectionAssume the parameter names are names of servicesQ: Problems with this method?

of services
Q: Problems with this method?


Слайд 76 Property Annotation
Dependency Injection
The $inject property is an array

Property AnnotationDependency InjectionThe $inject property is an array of services to inject.Q: Thoughts?

of services to inject.
Q: Thoughts?


Слайд 77 Inline Array Annotation
Dependency Injection
Define services inline when creating

Inline Array AnnotationDependency InjectionDefine services inline when creating the controller.Q: Thoughts?

the controller.
Q: Thoughts?


Слайд 78 Open CA. 2
In cardsController.js, create a cardsController module.

Open CA. 2In cardsController.js, create a cardsController module. Add cardsListController to

Add cardsListController to it.
In app.js, create a mainApp module.

Add cardsController as a dependency.

Magic the Gathering


Слайд 79 $http
$resources
Filters

Getting data
angular.js
angular-resource.js

$http$resourcesFiltersGetting dataangular.jsangular-resource.js

Слайд 80 What is a promise?
Promises

What is a promise?Promises

Слайд 81 Filters

Filters

Слайд 82 Hands On Lab: Build a Single Page Application

Hands On Lab: Build a Single Page Application (SPA) with ASP.NET Web API and Angular.jsLab Work

(SPA) with ASP.NET Web API and Angular.js
Lab Work


Слайд 83 Open CA.3
Modify cardsListController to read the data from

Open CA.3Modify cardsListController to read the data from all.json.Push each card

all.json.
Push each card from all.json onto the $scope.cards array,

so it’s available in the view.

Magic the Gathering


Слайд 84 angular-animate.js
SPA uses views to build UI
Angular.js uses routing

angular-animate.js SPA uses views to build UIAngular.js uses routing to define viewsAnimationsRouting and viewsangular-route.jsangular.jsangular-resource.js

to define views
Animations
Routing and views
angular-route.js
angular.js
angular-resource.js


Слайд 85 ngView
Routing
angular-route.js
angular.js
Module Components
A directive that complements the $route service.

ngViewRoutingangular-route.jsangular.jsModule ComponentsA directive that complements the $route service. It includes the

It includes the rendered template of the current route

into the main layout.

index.html

detail.html


Слайд 86 Route Provider
Routing
angular-route.js
angular.js
Module Components
$routeProvider is used for configuring routes.
config.route.js

Route ProviderRoutingangular-route.jsangular.jsModule Components$routeProvider is used for configuring routes.config.route.js

Слайд 87 Route Service
Routing
angular-route.js
angular.js
Module Components
$route is used for deep-linking URLs

Route ServiceRoutingangular-route.jsangular.jsModule Components$route is used for deep-linking URLs to controllers and views.controller.jstemplate.html

to controllers and views.
controller.js
template.html


Слайд 88 Route Parameters
Routing
angular-route.js
angular.js
Module Components
$routeParams allows you to retrieve the

Route ParametersRoutingangular-route.jsangular.jsModule Components$routeParams allows you to retrieve the current set of route parameters.controller.detail.js

current set of route parameters.
controller.detail.js


Слайд 89 HTML from view – no problem!
HTML file –

HTML from view – no problem!HTML file – use an IIS

use an IIS Rewrite rule

/cards.html -> /cards
ASP.NET + Angular Routing


Слайд 90 Open CA.4
Add a filter to app.js called filterAndReduce.

Open CA.4Add a filter to app.js called filterAndReduce. Look at index.html

Look at index.html to see the parameters it requires.
The

query parameter is optional, and it filters cards by the card.nameEn property.
The count property is always used.

Magic the Gathering


Слайд 91 Open CA.5
Create a route that responds to the

Open CA.5Create a route that responds to the URI /cards and

URI /cards and displays views/list.html. The cardsListController should be

executed.
Create a route that responds to the URI /cards/10 and displays views/detail.html. The cardDetailController should be executed.
Create a catchall route that redirects to /cards

Magic the Gathering


Слайд 92
Productivity Tools
http://www.sidewaffle.com

Productivity Toolshttp://www.sidewaffle.com

Слайд 93
Productivity Tools
Batarang – Chrome Extension
https://github.com/angular/angularjs-batarang

Productivity ToolsBatarang – Chrome Extensionhttps://github.com/angular/angularjs-batarang

Слайд 94 Module 6: Client-Side Development
Section 1: Development Tools
Lesson: Tools

Module 6: Client-Side DevelopmentSection 1: Development ToolsLesson: Tools

Слайд 95 jQuery – Tools / F12

jQuery – Tools / F12

Слайд 96 jQuery – in Visual Studio
Page Inspector

jQuery – in Visual StudioPage Inspector

Слайд 97 Module Summary
MVC 6 support for client-side through default

Module SummaryMVC 6 support for client-side through default project templateBootstrap for

project template
Bootstrap for UI styling
JavaScript, jQuery and AJAX for

scripting
Single Page Application fundamentals and frameworks

Слайд 98 Lab: Client-Side Development

Lab: Client-Side Development

  • Имя файла: net-framework-developing-modern-web-apps-with-aspnet-mvc.pptx
  • Количество просмотров: 111
  • Количество скачиваний: 0