简体   繁体   中英

Rails + AngularJS app, what should the rails controllers respond with?

I'm a newbie in AngularJS, and I'm trying to build a Rails-Angular web app. I designed the app to have a main layout with header and footer, and nested layouts for each main section of the app. I'm using Angular UI-Router to use nested views but I can't seem to understand how should I structure the router states and what should my controllers respond.

With all the HTML in angular templates, with what should my rails controllers respond? JSON even if I'm not implementing a API like app?

Thanks

You should have something like the following in your controller actions for your rails/angular interactions:

respond_to do |format|
  format.json {render :json => @object.to_json}
end 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM