Rails + AngularJs web app
I am about to create an AngularJS / Rails application, but I am new to development with AngularJS. So I have one question: should I divide my project into 2 parts, the first is just HTML / CSS / JS code and the second is the Rails API? I can also do all the work on a Rails project. Which should I prefer? Thank you in advance!
source to share
Personally, I think the cleanest way is to put files html
in a folder public
. Also, it will make it easier to send Angular routes to your files html
, since you don't have to mix .erb
with yours javascript
, which also gives you the ability to use clean coffeescript
everywhere (you can't print files .coffee.erb
).
Folder structure for all my Angular apps:
Angular coffee files:
app/assets/javascripts/angular/
In it I have separate folders for services and dispatcher directives. In the controllers folder, I have the same namespace happening as in the Rails controllers folder.
So, if there is a content namespace that I have preferences in and media controllers inside it, then it looks the same in the Angular folder.
Angular template files:
public/templates/
In public/templates
where I store the files .html
, I follow the way I relay the folder and file names and also keep the namespace. So if the users folder has an index page and a show page, then I also have show.html
and index.html
.
Here are some very good examples of people making Angular - Rails applications:
source to share