AngularJS for RubyistsIt’s like sinatra but for clients
Tom Cartwright @tomcartwrightuk
!keepmebooked.com
tomcartwright.net
Framework or library?
Library Framework
It has conventions (well sort of)
EmberBackbone Angular
Rails setup
This blank template is needed to stop rails freaking out - there is almost certainly a better way of handling this.
config/routes.rb
app/controllers/angular_controller.rb
app/views/angular/app.html.erb
Setup some routingapp/assets/javascripts/app/app.js
…and a controllerapp/assets/javascripts/app/controllers.js
As if by magic…some binding occurs
…but how?
Dirty checkingCheck $scopes and copy
Check again against the copies
Repaint DOM if required
$resource service
app/assets/javascripts/app/resources.js
app/assets/javascripts/app/resources.js
app/assets/javascripts/app/controllers.js
Testing
For unit testing - use Jasmine
spec/javascripts/controller…/dashboardControllerSpec.js
spec/javascripts/controller…/dashboardControllerSpec.js
Huzzah!
The API is doesn’t have to be the source of truth
Thank you $watching
Github ・Twitter @tomcartwrightuk
$scope.$watch('forQuestions', ! function(silence, question) {! console.log(possibleEruditeResponse);! }!});
Like the sound of this AngularJS stuff? Keepmebooked is hiring