Angularjs 在列表中列出Rails API数据

Angularjs 在列表中列出Rails API数据,angularjs,ruby-on-rails-4,Angularjs,Ruby On Rails 4,我发现并得到了这个例外: Expected response to contain an array but got an object 因为 isArray:true 如果我把它弄错,这个例外就会消失 {"themes":[{"id":1,"name":"This is first then","description":"This is first then"},{"id":2,"name":"Second Themes","description":"Second Themes"},{"

我发现并得到了这个例外:

Expected response to contain an array but got an object
因为 isArray:true 如果我把它弄错,这个例外就会消失

{"themes":[{"id":1,"name":"This is first then","description":"This is first then"},{"id":2,"name":"Second Themes","description":"Second Themes"},{"id":3,"name":"This is $th theme","description":"This is $th theme"}]
}
但我不知道如何从这个json中检索数据

<tr ng-show="themes.length" ng-repeat="theme in themes">
                <td>{{theme.name}}</td>
                <td>{{theme.description}}</td>
            </tr>

{{theme.name}
{{theme.description}}
它什么也不显示

请帮助

$scope.obj={“主题”:[{“id”:1,“name”:“This is first then”,“description”:“This is first then”,“description”:“This is first them”},{“id”:2,“name”:“Second themes”,“description”:“Second themes”},{“id”:3,“name”:“This is$th themes”,“description”:“This is$th theme”}
$scope.obj = {"themes":[{"id":1,"name":"This is first then","description":"This is first then"},{"id":2,"name":"Second Themes","description":"Second Themes"},{"id":3,"name":"This is $th theme","description":"This is $th theme"}]}

<tr ng-show="obj.themes.length > 0" ng-repeat="theme in obj.themes">
     <td>{{theme.name}}</td>
     <td>{{theme.description}}</td>
</tr>
{{theme.name} {{theme.description}}
尝试修改您的json响应,如下所示:

[{"id":1,"name":"This is first then","description":"This is first then","created_at":"2014-10-08T10:37:08.208Z"},{"id":2,"name":"Second Themes","description":"Second Themes","created_at":"2014-10-08T11:28:54.900Z"},{"id":4,"name":"4th theme","description":"4th theme","created_at":"2014-10-09T05:13:35.605Z"}]
您可以从rails主题/index.json中执行此操作

object false
child(@themes => :themes) do
  extends "themes/show"
end
将其修改为:

object @themes
attributes :id, :name, :description, :created_at
并在您的资源中设置
isArray:true