简体   繁体   English

Rails + AngularJS应用程序,Rails控制器应该响应什么?

[英]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. 我是AngularJS的新手,并且正在尝试构建Rails-Angular Web应用程序。 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. 我正在使用Angular UI-Router来使用嵌套视图,但似乎无法理解如何构造路由器状态以及控制器应如何响应。

With all the HTML in angular templates, with what should my rails controllers respond? 使用角度模板中的所有HTML,rails控制器应该如何响应? JSON even if I'm not implementing a API like app? JSON,即使我未实现类似应用程序的API?

Thanks 谢谢

You should have something like the following in your controller actions for your rails/angular interactions: 用于Rails / Angular交互的控制器操作中应具有以下类似内容:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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