SlideShare a Scribd company logo
1 of 39
Download to read offline
MVVM for the Web

 Angular vs. Knockout



         VS.
                        @basarat
Why MVVM?

• Cleaner user interface
 •   (used to be Cleaner code only)
• Designer / Developer separation
What makes MVVM Work?

• Two way DataBinding for properties
    •    With some form of interception options
• Command binding
• Templates




•       Names change but concepts remain the same.
MVVM the Knockout Way
How MVVM works for XAML

• INotifyPropertyChanged (INPC)
• ICommand Interface and Command Property
• DataTemplates / ItemTemplates
Enter Knockoutjs

• By Steve Sanderson.
  •   Works at microsoft.
• Highly inspired and directed by what was
  already there in XAML world.
  •   Perhaps to ease XAML people into HTML.
Knockout ViewModel similar to INPC

ko.obervable



ko.computed




ko.obervableArray
Knockout INPC View

• XAML View (dependency
  properties):



• Knockout View (bindings):
Knockout Commands

• XAML



• Knockout (click and other
  bindings)
Knockout DataTemplates

• XAML




• knockout
Knockout uses concept of Bindings
Angular js?
MVVM with AngularJS : Observables

• Don’t need them. Means your objects do not
  need an INPC type of implementation.
• “KO dependency tracking is a clever feature for
  a problem which angular does not have” –
  heard on StackOverflow
How does it know if anything changed?

• Angular remembers the value and compares it
  to previous value.
• This is basic dirty checking. If there is a change
  in value, then it fires the change event.
• To know when angular should check the new
  value it we have scope.
Quick AngularJS tutorial

• http://jsfiddle.net/basarat/V9sYB/
Why Angular chose a different method?

• Better syntax, especially for templates
  •   Google plans to make it a web standard so browsers
      can do this natively.
• Change listeners fire immediately on
  setter, which is a problem, since the change
  listener can further change data, which fires
  more change events.
Quick AngularJS tutorial 2

• How browsers could support it
  natively
Angular js performance

• Humans are
  •   Slow – anything faster than 50ms is imperceptible
  •   Limited - can't really show more than about 2000
      pieces of information to a human
• Can you do 2000 comparisons in 50 ms even
  on slow browsers? That means that you have
  25us per comparison.
MVVM the Angular Way
Observables : ViewModel

•       https://github.com/basarat/ChessClock
•       Standard javascript properties your scope
•       Really good with Typescript




•       Angular folks call their framework MV* i.e.
    •     Model View Whatever
•       But like to name it Controller
Observables : The view

• {{property}} syntax
Filters

• Similar to XAML
  IValueConverter but One way
  binding for display
Commands

• The VM




• The View
Templates
Angular JS uses concept of directives
Which one should you use?


Performance
jsPref
http://jsperf.com/angularjs-vs-knockoutjs
Which one should you use?


Browser Support
Angular

• http://docs.angularjs.org/misc/faq
 •   We run our extensive test suite against the following
     browsers: Safari, Chrome, Firefox, Opera, IE8, IE9
     and mobile browsers (Android, Chrome Mobile, iOS
     Safari)
• Yahoo’s Class A browser
Knockout

•       http://knockoutjs.com/documentation/browser-
        support.html
    •    Mozilla Firefox 2.0+ (latest version tested = 3.6.8)
    •    Google Chrome (tested on version 5 for Windows and Mac;
         should work on older versions too)
    •    Microsoft Internet Explorer 6, 7, 8, 9, 10
    •    Apple Safari (tested on Windows Safari version 5, Mac OS X
         Safari version 3.1.2, and iPhone Safari for iOS 4; should work on
         newer/older versions too)
    •    Opera 10 for Windows
•       Knockout was also found to work on the following
        browsers (though we don’t recheck these for every
        release):
    •    Opera Mini
    •    Google Android OS browser (OS version 2.2)
Which one should you use?


Popularity Contest
Knockout vs. Angular

• Google Searches




• StackOverflow tags ( as of feb 2013)
  •   Knockout : 4,304
  •   Angular : 2,794
Decisive

• Stared on Github (as of feb 2013)
  •   https://github.com/angular/angular.js : 7072
  •   https://github.com/SteveSanderson/knockout : 3011
Which one should you use?


Debugging
Batarang

• Dedicated Debugging tool for
  angular.




• None for knockout as of yet.
Conclusion


The world really needs both
Choice (my opinion)

•   Performance : Angular
•   Legacy Browser (specifically IE) : Knockout
•   MS bubble : Knockout
•   Popularity : Angular
•   Debugging : Angular
•   Awesomest Web App Ever : Angular
Links

•       Help Knockout
    •     http://knockoutjs.com/documentation/introduction.html
•       Help Angular
    •     http://docs.angularjs.org/guide/concepts
    •     https://github.com/angular/angular.js/wiki/JsFiddle-Examples
•       Comparisons
    •     http://stackoverflow.com/questions/9682092/databinding-in-
          angularjs
    •     http://litebyte.net/blog/?p=135
    •     TODO App in both: http://addyosmani.github.com/todomvc/
Thank you

• http://basarat.com
• basaratali@gmail.com
• @basarat

More Related Content

What's hot

jQuery Conference 2012 keynote
jQuery Conference 2012 keynotejQuery Conference 2012 keynote
jQuery Conference 2012 keynotedmethvin
 
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Transforming Front-End Disaster Code™ Into A Maintainable MasterpieceTransforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Transforming Front-End Disaster Code™ Into A Maintainable MasterpieceDan Gribbin
 
jQuery Chicago 2014 - Next-generation JavaScript Testing
jQuery Chicago 2014 - Next-generation JavaScript TestingjQuery Chicago 2014 - Next-generation JavaScript Testing
jQuery Chicago 2014 - Next-generation JavaScript TestingVlad Filippov
 
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
 
Testing Mobile JavaScript
Testing Mobile JavaScriptTesting Mobile JavaScript
Testing Mobile JavaScriptjeresig
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondSpike Brehm
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jeresig
 
Going Node.js at Netflix
Going Node.js at NetflixGoing Node.js at Netflix
Going Node.js at Netflixmicahr
 
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical UniversityASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical UniversitySyed Shanu
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptSpike Brehm
 
Node PDX: Intro to Sails.js
Node PDX: Intro to Sails.jsNode PDX: Intro to Sails.js
Node PDX: Intro to Sails.jsMike McNeil
 
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
 
Javascript Frameworks Comparison
Javascript Frameworks ComparisonJavascript Frameworks Comparison
Javascript Frameworks ComparisonDeepu S Nath
 
Building great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiBuilding great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiMaurice De Beijer [MVP]
 
Frontend architecture design for large(r) team final
Frontend architecture design for large(r) team   finalFrontend architecture design for large(r) team   final
Frontend architecture design for large(r) team finalChadchapol Vittavutkarnvej
 
Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Matt Raible
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp ArchitectureMorgan Cheng
 

What's hot (20)

jQuery Conference 2012 keynote
jQuery Conference 2012 keynotejQuery Conference 2012 keynote
jQuery Conference 2012 keynote
 
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Transforming Front-End Disaster Code™ Into A Maintainable MasterpieceTransforming Front-End Disaster Code™ Into A Maintainable Masterpiece
Transforming Front-End Disaster Code™ Into A Maintainable Masterpiece
 
Spa with angular
Spa with angularSpa with angular
Spa with angular
 
jQuery Chicago 2014 - Next-generation JavaScript Testing
jQuery Chicago 2014 - Next-generation JavaScript TestingjQuery Chicago 2014 - Next-generation JavaScript Testing
jQuery Chicago 2014 - Next-generation JavaScript Testing
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
Testing Mobile JavaScript
Testing Mobile JavaScriptTesting Mobile JavaScript
Testing Mobile JavaScript
 
Building a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and BeyondBuilding a Single-Page App: Backbone, Node.js, and Beyond
Building a Single-Page App: Backbone, Node.js, and Beyond
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010
 
Going Node.js at Netflix
Going Node.js at NetflixGoing Node.js at Netflix
Going Node.js at Netflix
 
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical UniversityASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
ASP.NET MVC, AngularJS CRUD for Azerbaijan Technical University
 
General Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScriptGeneral Assembly Workshop: Advanced JavaScript
General Assembly Workshop: Advanced JavaScript
 
Node PDX: Intro to Sails.js
Node PDX: Intro to Sails.jsNode PDX: Intro to Sails.js
Node PDX: Intro to Sails.js
 
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
 
Vue js for beginner
Vue js for beginner Vue js for beginner
Vue js for beginner
 
Javascript Frameworks Comparison
Javascript Frameworks ComparisonJavascript Frameworks Comparison
Javascript Frameworks Comparison
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
Building great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapiBuilding great spa’s with angular js, asp.net mvc and webapi
Building great spa’s with angular js, asp.net mvc and webapi
 
Frontend architecture design for large(r) team final
Frontend architecture design for large(r) team   finalFrontend architecture design for large(r) team   final
Frontend architecture design for large(r) team final
 
Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016Testing Angular 2 Applications - Rich Web 2016
Testing Angular 2 Applications - Rich Web 2016
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp Architecture
 

Viewers also liked

Currículo Nacional de la Educación Básica
Currículo Nacional de la Educación BásicaCurrículo Nacional de la Educación Básica
Currículo Nacional de la Educación BásicaDiego Ponce de Leon
 
32 ways to make your blog suck less
32 ways to make your blog suck less32 ways to make your blog suck less
32 ways to make your blog suck lessScott Hanselman
 
Metodología de la investigacióm
Metodología de la investigaciómMetodología de la investigacióm
Metodología de la investigaciómPaul Itusaca Canaza
 
Proyectos_de_innovacion
Proyectos_de_innovacionProyectos_de_innovacion
Proyectos_de_innovacionWebMD
 
1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)
1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)
1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)Geohistoria23
 
Error messages
Error messagesError messages
Error messagesrtinkelman
 
Gfpi f-019 guia de aprendizaje 01 tda orientar fpi
Gfpi f-019 guia de aprendizaje 01 tda orientar fpiGfpi f-019 guia de aprendizaje 01 tda orientar fpi
Gfpi f-019 guia de aprendizaje 01 tda orientar fpilisbet bravo
 
Análisis situacional integral de salud final
 Análisis situacional integral de salud final Análisis situacional integral de salud final
Análisis situacional integral de salud finalEstefanía Echeverría
 
JULIOPARI - Elaborando un Plan de Negocios
JULIOPARI - Elaborando un Plan de NegociosJULIOPARI - Elaborando un Plan de Negocios
JULIOPARI - Elaborando un Plan de NegociosJulio Pari
 
Training Schrijven voor het Web
Training Schrijven voor het WebTraining Schrijven voor het Web
Training Schrijven voor het WebSimone Levie
 
El emprendedor y el empresario profesional cert
El emprendedor y el empresario profesional certEl emprendedor y el empresario profesional cert
El emprendedor y el empresario profesional certMaestros Online
 
1ºBACH Economía Tema 5 Oferta y demanda
1ºBACH Economía Tema 5 Oferta y demanda1ºBACH Economía Tema 5 Oferta y demanda
1ºBACH Economía Tema 5 Oferta y demandaGeohistoria23
 
Primer Paquete Económico 2017 Zacatecas (2/9)
Primer Paquete Económico 2017 Zacatecas (2/9)Primer Paquete Económico 2017 Zacatecas (2/9)
Primer Paquete Económico 2017 Zacatecas (2/9)Zacatecas TresPuntoCero
 
Onderzoeksrapport acrs v3.0_definitief
Onderzoeksrapport acrs v3.0_definitiefOnderzoeksrapport acrs v3.0_definitief
Onderzoeksrapport acrs v3.0_definitiefrloggen
 
Como hacer un plan de negocios
Como hacer un plan de negociosComo hacer un plan de negocios
Como hacer un plan de negociosXPINNERPablo
 

Viewers also liked (20)

Proyecto Formativo
Proyecto FormativoProyecto Formativo
Proyecto Formativo
 
Currículo Nacional de la Educación Básica
Currículo Nacional de la Educación BásicaCurrículo Nacional de la Educación Básica
Currículo Nacional de la Educación Básica
 
32 ways to make your blog suck less
32 ways to make your blog suck less32 ways to make your blog suck less
32 ways to make your blog suck less
 
Metodología de la investigacióm
Metodología de la investigaciómMetodología de la investigacióm
Metodología de la investigacióm
 
"Protección de la salud mental luego del terremoto y tsunami del 27 de febrer...
"Protección de la salud mental luego del terremoto y tsunami del 27 de febrer..."Protección de la salud mental luego del terremoto y tsunami del 27 de febrer...
"Protección de la salud mental luego del terremoto y tsunami del 27 de febrer...
 
Componentes de un Plan de Negocios
Componentes de un Plan de NegociosComponentes de un Plan de Negocios
Componentes de un Plan de Negocios
 
Proyectos_de_innovacion
Proyectos_de_innovacionProyectos_de_innovacion
Proyectos_de_innovacion
 
1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)
1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)
1ºBACH ECONOMÍA Repaso temas 5 6-7 (gh23)
 
Error messages
Error messagesError messages
Error messages
 
Gfpi f-019 guia de aprendizaje 01 tda orientar fpi
Gfpi f-019 guia de aprendizaje 01 tda orientar fpiGfpi f-019 guia de aprendizaje 01 tda orientar fpi
Gfpi f-019 guia de aprendizaje 01 tda orientar fpi
 
Análisis situacional integral de salud final
 Análisis situacional integral de salud final Análisis situacional integral de salud final
Análisis situacional integral de salud final
 
JULIOPARI - Elaborando un Plan de Negocios
JULIOPARI - Elaborando un Plan de NegociosJULIOPARI - Elaborando un Plan de Negocios
JULIOPARI - Elaborando un Plan de Negocios
 
Training Schrijven voor het Web
Training Schrijven voor het WebTraining Schrijven voor het Web
Training Schrijven voor het Web
 
PMP Sonora Saludable 2010 2015
PMP Sonora Saludable 2010   2015  PMP Sonora Saludable 2010   2015
PMP Sonora Saludable 2010 2015
 
El emprendedor y el empresario profesional cert
El emprendedor y el empresario profesional certEl emprendedor y el empresario profesional cert
El emprendedor y el empresario profesional cert
 
1ºBACH Economía Tema 5 Oferta y demanda
1ºBACH Economía Tema 5 Oferta y demanda1ºBACH Economía Tema 5 Oferta y demanda
1ºBACH Economía Tema 5 Oferta y demanda
 
Tears In The Rain
Tears In The RainTears In The Rain
Tears In The Rain
 
Primer Paquete Económico 2017 Zacatecas (2/9)
Primer Paquete Económico 2017 Zacatecas (2/9)Primer Paquete Económico 2017 Zacatecas (2/9)
Primer Paquete Económico 2017 Zacatecas (2/9)
 
Onderzoeksrapport acrs v3.0_definitief
Onderzoeksrapport acrs v3.0_definitiefOnderzoeksrapport acrs v3.0_definitief
Onderzoeksrapport acrs v3.0_definitief
 
Como hacer un plan de negocios
Como hacer un plan de negociosComo hacer un plan de negocios
Como hacer un plan de negocios
 

Similar to Mvvm knockout vs angular

State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conferencedmethvin
 
Angular2.0@Shanghai0319
Angular2.0@Shanghai0319Angular2.0@Shanghai0319
Angular2.0@Shanghai0319Bibby Chung
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptTroy Miles
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Ganesh Kondal
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.jsKasey McCurdy
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - IntroductionSagar Acharya
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS LimitationsValeri Karpov
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS LimitationsAll Things Open
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierMiroslav Resetar
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners WorkshopSathish VJ
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersMark Leusink
 
JavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsJavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsTimmy Kokke
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSGunnar Hillert
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - IntroductionSenthil Kumar
 
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularEscaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularMark Leusink
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumTechday7
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 

Similar to Mvvm knockout vs angular (20)

State of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront ConferenceState of jQuery - AspDotNetStorefront Conference
State of jQuery - AspDotNetStorefront Conference
 
Angular2.0@Shanghai0319
Angular2.0@Shanghai0319Angular2.0@Shanghai0319
Angular2.0@Shanghai0319
 
Protractor survival guide
Protractor survival guideProtractor survival guide
Protractor survival guide
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Angular js
Angular jsAngular js
Angular js
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5Tech io spa_angularjs_20130814_v0.9.5
Tech io spa_angularjs_20130814_v0.9.5
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
 
Angular JS - Introduction
Angular JS - IntroductionAngular JS - Introduction
Angular JS - Introduction
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS Limitations
 
Conquering AngularJS Limitations
Conquering AngularJS LimitationsConquering AngularJS Limitations
Conquering AngularJS Limitations
 
Swagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlierSwagger - Making REST APIs friendlier
Swagger - Making REST APIs friendlier
 
AngularJS Beginners Workshop
AngularJS Beginners WorkshopAngularJS Beginners Workshop
AngularJS Beginners Workshop
 
A 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developersA 20 minute introduction to AngularJS for XPage developers
A 20 minute introduction to AngularJS for XPage developers
 
JavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform appsJavaScript in Universal Windows Platform apps
JavaScript in Universal Windows Platform apps
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 
Valentine with Angular js - Introduction
Valentine with Angular js - IntroductionValentine with Angular js - Introduction
Valentine with Angular js - Introduction
 
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and AngularEscaping the yellow bubble - rewriting Domino using MongoDb and Angular
Escaping the yellow bubble - rewriting Domino using MongoDb and Angular
 
Javascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to TitaniumJavascript Best Practices and Intro to Titanium
Javascript Best Practices and Intro to Titanium
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 

Mvvm knockout vs angular

  • 1. MVVM for the Web Angular vs. Knockout VS. @basarat
  • 2. Why MVVM? • Cleaner user interface • (used to be Cleaner code only) • Designer / Developer separation
  • 3. What makes MVVM Work? • Two way DataBinding for properties • With some form of interception options • Command binding • Templates • Names change but concepts remain the same.
  • 5. How MVVM works for XAML • INotifyPropertyChanged (INPC) • ICommand Interface and Command Property • DataTemplates / ItemTemplates
  • 6. Enter Knockoutjs • By Steve Sanderson. • Works at microsoft. • Highly inspired and directed by what was already there in XAML world. • Perhaps to ease XAML people into HTML.
  • 7. Knockout ViewModel similar to INPC ko.obervable ko.computed ko.obervableArray
  • 8. Knockout INPC View • XAML View (dependency properties): • Knockout View (bindings):
  • 9. Knockout Commands • XAML • Knockout (click and other bindings)
  • 11. Knockout uses concept of Bindings
  • 13. MVVM with AngularJS : Observables • Don’t need them. Means your objects do not need an INPC type of implementation. • “KO dependency tracking is a clever feature for a problem which angular does not have” – heard on StackOverflow
  • 14. How does it know if anything changed? • Angular remembers the value and compares it to previous value. • This is basic dirty checking. If there is a change in value, then it fires the change event. • To know when angular should check the new value it we have scope.
  • 15. Quick AngularJS tutorial • http://jsfiddle.net/basarat/V9sYB/
  • 16. Why Angular chose a different method? • Better syntax, especially for templates • Google plans to make it a web standard so browsers can do this natively. • Change listeners fire immediately on setter, which is a problem, since the change listener can further change data, which fires more change events.
  • 17. Quick AngularJS tutorial 2 • How browsers could support it natively
  • 18. Angular js performance • Humans are • Slow – anything faster than 50ms is imperceptible • Limited - can't really show more than about 2000 pieces of information to a human • Can you do 2000 comparisons in 50 ms even on slow browsers? That means that you have 25us per comparison.
  • 20. Observables : ViewModel • https://github.com/basarat/ChessClock • Standard javascript properties your scope • Really good with Typescript • Angular folks call their framework MV* i.e. • Model View Whatever • But like to name it Controller
  • 21. Observables : The view • {{property}} syntax
  • 22. Filters • Similar to XAML IValueConverter but One way binding for display
  • 25. Angular JS uses concept of directives
  • 26. Which one should you use? Performance
  • 28. Which one should you use? Browser Support
  • 29. Angular • http://docs.angularjs.org/misc/faq • We run our extensive test suite against the following browsers: Safari, Chrome, Firefox, Opera, IE8, IE9 and mobile browsers (Android, Chrome Mobile, iOS Safari) • Yahoo’s Class A browser
  • 30. Knockout • http://knockoutjs.com/documentation/browser- support.html • Mozilla Firefox 2.0+ (latest version tested = 3.6.8) • Google Chrome (tested on version 5 for Windows and Mac; should work on older versions too) • Microsoft Internet Explorer 6, 7, 8, 9, 10 • Apple Safari (tested on Windows Safari version 5, Mac OS X Safari version 3.1.2, and iPhone Safari for iOS 4; should work on newer/older versions too) • Opera 10 for Windows • Knockout was also found to work on the following browsers (though we don’t recheck these for every release): • Opera Mini • Google Android OS browser (OS version 2.2)
  • 31. Which one should you use? Popularity Contest
  • 32. Knockout vs. Angular • Google Searches • StackOverflow tags ( as of feb 2013) • Knockout : 4,304 • Angular : 2,794
  • 33. Decisive • Stared on Github (as of feb 2013) • https://github.com/angular/angular.js : 7072 • https://github.com/SteveSanderson/knockout : 3011
  • 34. Which one should you use? Debugging
  • 35. Batarang • Dedicated Debugging tool for angular. • None for knockout as of yet.
  • 37. Choice (my opinion) • Performance : Angular • Legacy Browser (specifically IE) : Knockout • MS bubble : Knockout • Popularity : Angular • Debugging : Angular • Awesomest Web App Ever : Angular
  • 38. Links • Help Knockout • http://knockoutjs.com/documentation/introduction.html • Help Angular • http://docs.angularjs.org/guide/concepts • https://github.com/angular/angular.js/wiki/JsFiddle-Examples • Comparisons • http://stackoverflow.com/questions/9682092/databinding-in- angularjs • http://litebyte.net/blog/?p=135 • TODO App in both: http://addyosmani.github.com/todomvc/
  • 39. Thank you • http://basarat.com • basaratali@gmail.com • @basarat