I want to display my database entries. Angular repeats list items but doesn't display any values. The entries database has a title column.
View:
<div ng-controller="EntryCtrl">
<h2>Angular Display</h2>
<ul>
<li ng-repeat="entry in entries">
{{entry.title}}
</li>
</ul>
</div>
Coffee-script:
app = angular.module("Resume", ["ngResource"])
app.factory "Entry", ["$resource", ($resource) ->
$resource("/entries/:id", {id: "@id"}, {update: {method: "GET"}})
]
@EntryCtrl = ["$scope", "Entry", ($scope, Entry) ->
$scope.entries = Entry.get()
]
$resource.get is used for fetching single object instance:
$scope.entry = Entry.get({id:123}, callback);
and $resource.query is used for retrieving a collection:
$scope.entries = Entry.query();
To fix, I had to add:
respond_to :json, :html
and:
respond_with Entry.all
...to the controller.