Take the tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a existing project in Ruby on Rails.

What is the best way to use AngularJS in Ruby on Rails app?

I want to use AngularJs for only specified modules, not for create SPA. This is good way?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

What I have seen colleagues do in order to achieve this sort of integration with an existing rails app is:

  • Include angular.js and relevant dependencies in the specific app pages that are to be 'angularized'
  • Interpolate whatever data is needed to bootstrap the angular controller into the html template which contains the angular app. This might include data about the resource being operated on. I've seen this done by rendering a RABL template inside of a haml/erb template.
  • Using that interpolated data, call whatever API methods you need to get additional data on the fly. This is usually just a matter of implementing json handlers for routes you've already created.

I can't say whether this is best practice, but its an easy way to get started fast.

Best of luck, angular is a very enjoyable tool to work with once you get used to it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.