SlideShare a Scribd company logo
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/

More Related Content

What's hot

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 App
Luca Mearelli
 
Testing Against AWS APIs Go
Testing Against AWS APIs GoTesting Against AWS APIs Go
Testing Against AWS APIs Go
Stephen 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 framework
techmemo
 
優しいWAFの作り方
優しいWAFの作り方優しいWAFの作り方
優しいWAFの作り方techmemo
 
Nevermore Unit Testing
Nevermore Unit TestingNevermore Unit Testing
Nevermore Unit Testing
Ihsan Fauzi Rahman
 
fabfile.py
fabfile.pyfabfile.py
fabfile.py
Corey Oordt
 
Say It With Javascript
Say It With JavascriptSay It With Javascript
Say It With Javascript
Giovanni Scerra ☃
 
Containers & Dependency in Ember.js
Containers & Dependency in Ember.jsContainers & Dependency in Ember.js
Containers & Dependency in Ember.js
Matthew Beale
 
Mirage For Beginners
Mirage For BeginnersMirage For Beginners
Mirage For Beginners
Wilson Su
 
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
Enrique Oriol Bermúdez
 
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
ikailan
 
Complex Sites with Silex
Complex Sites with SilexComplex Sites with Silex
Complex Sites with Silex
Chris Tankersley
 
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
Codemotion
 
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 Py
Eric 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 mirage
Krzysztof Bialek
 
What happens in laravel 4 bootstraping
What happens in laravel 4 bootstrapingWhat happens in laravel 4 bootstraping
What happens in laravel 4 bootstraping
Jace 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
 

What's hot (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
 

Viewers also liked

Spotify
SpotifySpotify
Spotify
Petr Bela
 
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 century
Petr 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 Dementia
BrightStar Care
 
Eye Care Resources for Older Adults
Eye Care Resources for Older AdultsEye Care Resources for Older Adults
Eye Care Resources for Older Adults
BrightStar 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 Brief
AC Peoples
 
Prostate Cancer Resources
Prostate Cancer ResourcesProstate Cancer Resources
Prostate Cancer Resources
BrightStar Care
 

Viewers also liked (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
 

Similar to AngularJS Tips&Tricks

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
Daniel Spector
 
Practical Celery
Practical CeleryPractical Celery
Practical Celery
Cameron Maske
 
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
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
Daniel Cukier
 
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.js
Roman 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 JRuby
Nick 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 js
Francois Zaninotto
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Elegant APIs
Elegant APIsElegant APIs
Elegant APIs
Andrew Timberlake
 
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
Future 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 byandreapaciolla
Andrea Paciolla
 
Javascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & AngularJavascript Memory leaks and Performance & Angular
Javascript Memory leaks and Performance & Angular
Erik Guzman
 

Similar to AngularJS Tips&Tricks (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
 

Recently uploaded

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 

AngularJS Tips&Tricks

  • 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/