SlideShare ist ein Scribd-Unternehmen logo
1 von 16
Downloaden Sie, um offline zu lesen
AngularJS
Tips&Tricks
(with	
  a	
  bit	
  of	
  Rails)




#angularjs     #rails     #karma       #jenkins
                                                  @petrbela
#sugarjs     #zeus      #chucknorris
What?




www.kdyjedes.cz	
  -­‐>	
  www.KJ.cz
Plan   1.	
  Rails	
  +	
  AngularJS

       2.	
  TesEng	
  in	
  AngularJS

       3.	
  AngularJS	
  Components

       4.	
  Extras

       5.	
  Q&A
1.	
  Rails	
  +	
  AngularJS
     >	
  app
     	
  	
  	
  >	
  assets
     	
  	
  	
  	
  	
  	
  >	
  javascripts
     	
  	
  	
  	
  	
  	
  	
  	
  	
  >	
  controllers
     	
  	
  	
  	
  	
  	
  	
  	
  	
  >	
  direcEves
     	
  	
  	
  	
  	
  	
  	
  	
  	
  >	
  filters
     	
  	
  	
  	
  	
  	
  	
  	
  	
  >	
  models
     	
  	
  	
  	
  	
  	
  	
  	
  	
  >	
  services
     	
  	
  	
  	
  	
  	
  	
  	
  	
  app.js




Structure	
  your	
  client-­‐side	
  app	
  similarly	
  as	
  a	
  Rails	
  app.
Declare	
  your	
  module	
  in	
  app.js	
  and	
  put	
  the	
  files	
  inside	
  dirs.
Or	
  see	
  github.com/angular/angular-­‐seed	
  for	
  a	
  server-­‐less	
  setup.
2.	
  How	
  we	
  test

“If you don’t like unit testing your product, most likely
  your customers won’t like to test it either.” -  Anonymous



  “A code that cannot be tested is flawed.” – Anonymous




Thanks	
  to	
  Dependency	
  InjecEon,	
  tesEng	
  in	
  Angular	
  is	
  easy.
Not	
  many	
  client-­‐side	
  JavaScript	
  libraries	
  can	
  say	
  that.
You	
  should	
  be	
  thankful	
  and	
  do	
  it.
Testacular	
  Karma Spectacular	
  tesEng	
  framework

A.	
  Unit	
  tesEng




Test	
  runner	
  made	
  by	
  @vojtajina	
  from	
  Angular’s	
  core	
  team.
Runs	
  Jasmine	
  (et	
  al.)	
  unit	
  tests	
  upon	
  each	
  file	
  save.
hps://github.com/karma-­‐runner/karma
Testacular	
  Karma Spectacular	
  tesEng	
  framework
     B.	
  E2E	
  tesEng




Karma	
  can	
  be	
  used	
  also	
  for	
  integraEon	
  tesEng.	
  Usage	
  is	
  similar
to	
  Selenium,	
  with	
  async	
  calls	
  in	
  Angular	
  handled	
  automaEcally.
hp://docs.angularjs.org/guide/dev_guide.e2e-­‐tesEng
Jenkins	
  CI
     Cloudbees.com




It’s	
  easy	
  to	
  setup	
  AngularJS	
  tesEng	
  env	
  on	
  a	
  CI	
  server.
E.g.	
  Cloudbees	
  provides	
  a	
  ready-­‐made	
  environment	
  package	
  at
hps://github.com/CloudBees-­‐community/angular-­‐js-­‐clickstart
3.	
  Components	
  Modules	
  we	
  use
>	
  app
	
  	
  	
  >	
  assets
	
  	
  	
  	
  	
  	
  >	
  javascripts
	
  	
  	
  	
  	
  	
  	
  	
  	
  app.js
angular.module('kdyjedes',	
  
['ngResource',	
  'rails',	
  'ui',	
  
'ui.bootstrap'])




You	
  can	
  load	
  exisEng	
  modules	
  (reusable	
  components)	
  inside	
  your
applicaEon	
  by	
  declaring	
  them	
  in	
  the	
  module	
  constructor.
Find	
  community-­‐submied	
  modules	
  at	
  hp://ngmodules.org/.
$resource	
  vs	
  railsResource
          angular.module('kdyjedes')
          .factory('Registrar',	
  	
  ['railsResourceFactory',	
  (railsResourceFactory)	
  -­‐>
          	
  	
  	
  Registrar	
  =	
  railsResourceFactory({url:	
  '/registrars',	
  name:	
  'registrar'})

          	
  	
  	
  #	
  API	
  compaEbility	
  with	
  $resource-­‐based	
  service
          	
  	
  	
  Registrar.prototype.$save	
  =	
  (success)	
  -­‐>
          	
  	
  	
  	
  	
  	
  this.create().then	
  (result)	
  -­‐>
          	
  	
  	
  	
  	
  	
  	
  	
  	
  success(result)
          	
  	
  	
  	
  	
  	
  
          	
  	
  	
  return	
  Registrar
          ])


$resource	
  is	
  a	
  wrapper	
  for	
  REST	
  API	
  calls	
  provided	
  by	
  Angular.
railsResource	
  adds	
  Promises,	
  data	
  manipulaEon	
  and	
  interceptors.
hps://github.com/tpodom/angularjs-­‐rails-­‐resource
DIY                           angular.module("myModule").factory	
  "socket",	
  ($rootScope)	
  -­‐>
                                  	
  	
  socket	
  =	
  io.connect()

                                  	
  	
  return	
  {
                                  	
  	
  	
  	
  on:	
  (eventName,	
  callback)	
  -­‐>
                                  	
  	
  	
  	
  	
  	
  socket.on	
  eventName,	
  -­‐>
                                  	
  	
  	
  	
  	
  	
  	
  	
  args	
  =	
  arguments
                                  	
  	
  	
  	
  	
  	
  	
  	
  $rootScope.$apply	
  -­‐>
                                  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  callback.apply(socket,	
  args)
                                  	
  	
  	
  	
  
                                  	
  	
  	
  	
  emit:	
  (eventName,	
  data,	
  callback)	
  -­‐>
                                  	
  	
  	
  	
  	
  	
  socket.emit	
  eventName,	
  data,	
  -­‐>
                                  	
  	
  	
  	
  	
  	
  	
  	
  args	
  =	
  arguments
                                  	
  	
  	
  	
  	
  	
  	
  	
  $rootScope.$apply	
  -­‐>
                                  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  callback.apply(socket,	
  args)	
  	
  if	
  callback
                                  	
  	
  }


Use	
  $rootScope.$apply	
  block	
  to	
  automaEcally	
  run	
  Angular’s
digesEng	
  cycle	
  that	
  updates	
  view	
  based	
  on	
  model	
  changes.
4.	
  Extras
SugarJS
Like	
  Underscore,	
  just	
  beer


      ['one','two','three'].first();

      [1,65,2,77,34].average();

      (5).daysAfter('Wednesday');

      'hello'.capitalize();

      [[1], 2, [3]].flatten();




JavaScript	
  on	
  steroids.	
  Safely	
  injects	
  convenient	
  methods
into	
  naEve	
  JS	
  objects,	
  strings	
  and	
  arrays.
hp://sugarjs.com/
Zeus                  Like	
  Spork,	
  just	
  beer
                      (Linux/Mac	
  only)




Run	
  an	
  always-­‐up	
  environment	
  to	
  instantly	
  start	
  console,
server,	
  tests	
  or	
  rake	
  tasks.
hps://github.com/burke/zeus
5.	
  Q&A

 @petrbela
 @kdyjedes
 @getChute
 @StudenEve
 @StartupKidsCZSK



                    Thank	
  You!
Credits

 1Sock http://www.flickr.com/photos/64025277@N00/333979587/

 alisdair http://www.flickr.com/photos/41143865@N00/135306281/

Weitere ähnliche Inhalte

Was ist angesagt?

Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With PythonLuca Mearelli
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your AppLuca Mearelli
 
Testing Against AWS APIs Go
Testing Against AWS APIs GoTesting Against AWS APIs Go
Testing Against AWS APIs GoStephen Scaffidi
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application frameworktechmemo
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方techmemo
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.jsMatthew Beale
 
Mirage For Beginners
Mirage For BeginnersMirage For Beginners
Mirage For BeginnersWilson Su
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010ikailan
 
The road to Ember.js 2.0
The road to Ember.js 2.0The road to Ember.js 2.0
The road to Ember.js 2.0Codemotion
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...Codemotion
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In PyEric ShangKuan
 
Rapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageRapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageKrzysztof Bialek
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingJace Ju
 
AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)Brian Swartzfager
 

Was ist angesagt? (20)

Controlling The Cloud With Python
Controlling The Cloud With PythonControlling The Cloud With Python
Controlling The Cloud With Python
 
A Little Backbone For Your App
A Little Backbone For Your AppA Little Backbone For Your App
A Little Backbone For Your App
 
Testing Against AWS APIs Go
Testing Against AWS APIs GoTesting Against AWS APIs Go
Testing Against AWS APIs Go
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方
 
Nevermore Unit Testing
Nevermore Unit TestingNevermore Unit Testing
Nevermore Unit Testing
 
fabfile.py
fabfile.pyfabfile.py
fabfile.py
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.js
 
Mirage For Beginners
Mirage For BeginnersMirage For Beginners
Mirage For Beginners
 
Boost your angular app with web workers
Boost your angular app with web workersBoost your angular app with web workers
Boost your angular app with web workers
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 
Complex Sites with Silex
Complex Sites with SilexComplex Sites with Silex
Complex Sites with Silex
 
The road to Ember.js 2.0
The road to Ember.js 2.0The road to Ember.js 2.0
The road to Ember.js 2.0
 
And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...And now you have two problems. Ruby regular expressions for fun and profit by...
And now you have two problems. Ruby regular expressions for fun and profit by...
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In Py
 
Rapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirageRapid prototyping and easy testing with ember cli mirage
Rapid prototyping and easy testing with ember cli mirage
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
 
AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)AngularJS $http Interceptors (Explanation and Examples)
AngularJS $http Interceptors (Explanation and Examples)
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 

Andere mochten auch

C:\fakepath\xsl final
C:\fakepath\xsl finalC:\fakepath\xsl final
C:\fakepath\xsl finalshivpriya
 
Education in the 21st century
Education in the 21st centuryEducation in the 21st century
Education in the 21st centuryPetr Bela
 
The Three Most Common Types of Dementia
The Three Most Common Types of DementiaThe Three Most Common Types of Dementia
The Three Most Common Types of DementiaBrightStar Care
 
Eye Care Resources for Older Adults
Eye Care Resources for Older AdultsEye Care Resources for Older Adults
Eye Care Resources for Older AdultsBrightStar Care
 
careStarter - My solution to the Cannes Lions Chimera Brief
careStarter - My solution to the Cannes Lions Chimera BriefcareStarter - My solution to the Cannes Lions Chimera Brief
careStarter - My solution to the Cannes Lions Chimera BriefAC Peoples
 
Prostate Cancer Resources
Prostate Cancer ResourcesProstate Cancer Resources
Prostate Cancer ResourcesBrightStar Care
 

Andere mochten auch (7)

Spotify
SpotifySpotify
Spotify
 
C:\fakepath\xsl final
C:\fakepath\xsl finalC:\fakepath\xsl final
C:\fakepath\xsl final
 
Education in the 21st century
Education in the 21st centuryEducation in the 21st century
Education in the 21st century
 
The Three Most Common Types of Dementia
The Three Most Common Types of DementiaThe Three Most Common Types of Dementia
The Three Most Common Types of Dementia
 
Eye Care Resources for Older Adults
Eye Care Resources for Older AdultsEye Care Resources for Older Adults
Eye Care Resources for Older Adults
 
careStarter - My solution to the Cannes Lions Chimera Brief
careStarter - My solution to the Cannes Lions Chimera BriefcareStarter - My solution to the Cannes Lions Chimera Brief
careStarter - My solution to the Cannes Lions Chimera Brief
 
Prostate Cancer Resources
Prostate Cancer ResourcesProstate Cancer Resources
Prostate Cancer Resources
 

Ähnlich wie AngularJS Tips&Tricks for Building Apps

Crossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkCrossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkDaniel Spector
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011Nick Sieger
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Railstielefeld
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
Introduction to Backbone.js
Introduction to Backbone.jsIntroduction to Backbone.js
Introduction to Backbone.jsRoman Kalyakin
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...murtazahaveliwala
 
Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular jsSlaven Tomac
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Paul King
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsFrancois Zaninotto
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Angular Performance: Then, Now and the Future. Todd Motto
Angular Performance: Then, Now and the Future. Todd MottoAngular Performance: Then, Now and the Future. Todd Motto
Angular Performance: Then, Now and the Future. Todd MottoFuture Insights
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciollaAndrea Paciolla
 
Javascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularJavascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularErik Guzman
 

Ähnlich wie AngularJS Tips&Tricks for Building Apps (20)

Crossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end FrameworkCrossing the Bridge: Connecting Rails and your Front-end Framework
Crossing the Bridge: Connecting Rails and your Front-end Framework
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Innovation and Security in Ruby on Rails
Innovation and Security in Ruby on RailsInnovation and Security in Ruby on Rails
Innovation and Security in Ruby on Rails
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
Introduction to Backbone.js
Introduction to Backbone.jsIntroduction to Backbone.js
Introduction to Backbone.js
 
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
Angular training - Day 3 - custom directives, $http, $resource, setup with ye...
 
Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular js
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Intro to Rack
Intro to RackIntro to Rack
Intro to Rack
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Elegant APIs
Elegant APIsElegant APIs
Elegant APIs
 
Angular Performance: Then, Now and the Future. Todd Motto
Angular Performance: Then, Now and the Future. Todd MottoAngular Performance: Then, Now and the Future. Todd Motto
Angular Performance: Then, Now and the Future. Todd Motto
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
 
Javascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularJavascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & Angular
 

Kürzlich hochgeladen

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

AngularJS Tips&Tricks for Building Apps

  • 1. AngularJS Tips&Tricks (with  a  bit  of  Rails) #angularjs #rails #karma #jenkins @petrbela #sugarjs #zeus #chucknorris
  • 3. Plan 1.  Rails  +  AngularJS 2.  TesEng  in  AngularJS 3.  AngularJS  Components 4.  Extras 5.  Q&A
  • 4. 1.  Rails  +  AngularJS >  app      >  assets            >  javascripts                  >  controllers                  >  direcEves                  >  filters                  >  models                  >  services                  app.js Structure  your  client-­‐side  app  similarly  as  a  Rails  app. Declare  your  module  in  app.js  and  put  the  files  inside  dirs. Or  see  github.com/angular/angular-­‐seed  for  a  server-­‐less  setup.
  • 5. 2.  How  we  test “If you don’t like unit testing your product, most likely your customers won’t like to test it either.” -  Anonymous “A code that cannot be tested is flawed.” – Anonymous Thanks  to  Dependency  InjecEon,  tesEng  in  Angular  is  easy. Not  many  client-­‐side  JavaScript  libraries  can  say  that. You  should  be  thankful  and  do  it.
  • 6. Testacular  Karma Spectacular  tesEng  framework A.  Unit  tesEng Test  runner  made  by  @vojtajina  from  Angular’s  core  team. Runs  Jasmine  (et  al.)  unit  tests  upon  each  file  save. hps://github.com/karma-­‐runner/karma
  • 7. Testacular  Karma Spectacular  tesEng  framework B.  E2E  tesEng Karma  can  be  used  also  for  integraEon  tesEng.  Usage  is  similar to  Selenium,  with  async  calls  in  Angular  handled  automaEcally. hp://docs.angularjs.org/guide/dev_guide.e2e-­‐tesEng
  • 8. Jenkins  CI Cloudbees.com It’s  easy  to  setup  AngularJS  tesEng  env  on  a  CI  server. E.g.  Cloudbees  provides  a  ready-­‐made  environment  package  at hps://github.com/CloudBees-­‐community/angular-­‐js-­‐clickstart
  • 9. 3.  Components  Modules  we  use >  app      >  assets            >  javascripts                  app.js angular.module('kdyjedes',   ['ngResource',  'rails',  'ui',   'ui.bootstrap']) You  can  load  exisEng  modules  (reusable  components)  inside  your applicaEon  by  declaring  them  in  the  module  constructor. Find  community-­‐submied  modules  at  hp://ngmodules.org/.
  • 10. $resource  vs  railsResource angular.module('kdyjedes') .factory('Registrar',    ['railsResourceFactory',  (railsResourceFactory)  -­‐>      Registrar  =  railsResourceFactory({url:  '/registrars',  name:  'registrar'})      #  API  compaEbility  with  $resource-­‐based  service      Registrar.prototype.$save  =  (success)  -­‐>            this.create().then  (result)  -­‐>                  success(result)                  return  Registrar ]) $resource  is  a  wrapper  for  REST  API  calls  provided  by  Angular. railsResource  adds  Promises,  data  manipulaEon  and  interceptors. hps://github.com/tpodom/angularjs-­‐rails-­‐resource
  • 11. DIY angular.module("myModule").factory  "socket",  ($rootScope)  -­‐>    socket  =  io.connect()    return  {        on:  (eventName,  callback)  -­‐>            socket.on  eventName,  -­‐>                args  =  arguments                $rootScope.$apply  -­‐>                    callback.apply(socket,  args)                emit:  (eventName,  data,  callback)  -­‐>            socket.emit  eventName,  data,  -­‐>                args  =  arguments                $rootScope.$apply  -­‐>                    callback.apply(socket,  args)    if  callback    } Use  $rootScope.$apply  block  to  automaEcally  run  Angular’s digesEng  cycle  that  updates  view  based  on  model  changes.
  • 13. SugarJS Like  Underscore,  just  beer ['one','two','three'].first(); [1,65,2,77,34].average(); (5).daysAfter('Wednesday'); 'hello'.capitalize(); [[1], 2, [3]].flatten(); JavaScript  on  steroids.  Safely  injects  convenient  methods into  naEve  JS  objects,  strings  and  arrays. hp://sugarjs.com/
  • 14. Zeus Like  Spork,  just  beer (Linux/Mac  only) Run  an  always-­‐up  environment  to  instantly  start  console, server,  tests  or  rake  tasks. hps://github.com/burke/zeus
  • 15. 5.  Q&A @petrbela @kdyjedes @getChute @StudenEve @StartupKidsCZSK Thank  You!
  • 16. Credits 1Sock http://www.flickr.com/photos/64025277@N00/333979587/ alisdair http://www.flickr.com/photos/41143865@N00/135306281/