ݺߣ

ݺߣShare a Scribd company logo
AngularJS for Rubyists
It’s like sinatra but for clients

Tom Cartwright
@tomcartwrightuk
!

keepmebooked.com
tomcartwright.net
Framework or library?
Library

Framework

Backbone

Angular

It has conventions (well sort of)

Ember
Rails setup
config/routes.rb

app/controllers/angular_controller.rb

app/views/angular/app.html.erb
This blank template is needed to stop rails freaking out - there
is almost certainly a better way of handling this.
Define an app
Setup some routing
app/assets/javascripts/app/app.js
…and a controller
app/assets/javascripts/app/controllers.js
A rendered page
As if by magic
…some binding occurs

…but how?
Dirty checking
Check $scopes and copy

Check again against the copies

Repaint DOM if required
Server communication
$resource service
app/assets/javascripts/app/resources.js
Err.. no
app/assets/javascripts/app/resources.js

app/assets/javascripts/app/controllers.js
Promises
Testing

For unit testing - use Jasmine
/Ჹٲ/DzԳٰDZ…/岹DzDzԳٰDZ.
/Ჹٲ/DzԳٰDZ…/岹DzDzԳٰDZ.

Huzzah!
Directives
The API is doesn’t have to be the source of truth
Thank you $watching
$scope.$watch('forQuestions', !
function(silence, question) {!
console.log(possibleEruditeResponse);!
}!
});

Github ・Twitter
@tomcartwrightuk

Like the sound of this AngularJS stuff? Keepmebooked is hiring

More Related Content

Angular for rubyists