Ruby on Rails with AngularJS: "Argument [...] is not a function, got undefined"
I have just spent several hours trying to figure out what is wrong with my newly created application.
Error: Argument [...] is not a function, got undefined
It turns out that problem... can be anywhere.
What's wrong?
It usually means we have forgotten about some braces, colons, semicolons, commas, dots etc. In short, there is a syntax error.
But I have been reading my code very carefully and there was no mistake.
What worked for me?
I named my main javascript file main.js. Don't do it.
Name it app.js instead and everything should be fine.
Written by Sebastian Muszyński
Related protips
2 Responses
After installing angularjs-rails gem. I cant find main.js, and if I create a new file app.js where should I put it?
I haven't used angularjs-rails gem. However, you should create all your js-related files under app/assets/javascripts folder if it's a typical rails application.
Have a fresh tip? Share with Coderwall community!
Angular apps often share the page with analytics and payment scripts that are not Angular modules. Those scripts execute on the same origin as the framework.
Security insights from Cside