1

I cannot get Angular to work with Rails asset pipeline. I have:

application.js

//= require angular
angular.module('myApp', [])
  .config([function() {
    console.log('In config.');
  }]);

application.html.erb

<!DOCTYPE html>
<html>
  <head>
    <%= javascript_include_tag 'application' %>
  </head>
  <body ng-app="myApp"></body>
</html>

When I load the page I do not see the expected "In config" in the console. Where are no errors prompted, the source is loaded correctly. After refreshing the page two times, on the third load the console message does appear eventually.

If I replace <%= javascript_include_tag 'application' %> with simply <script src="/assets/application.js"></script>, the application does work as expected.

What am I missing here?

paudam
  • 103
  • 1
  • 1
  • 4
  • I see absolutely no reason – apneadiving May 10 '15 at 20:18
  • unsure if it contributes to the problem, but make sure to either disable turbolinks, or [set it up so they can work together](http://stackoverflow.com/questions/14797935/using-angularjs-with-turbolinks) – Mario May 10 '15 at 21:05

0 Answers0