Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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()
]
share|improve this question
add comment

2 Answers

$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();
share|improve this answer
    
The get/query issue was a bi-product of troubleshooting. Thanks for the clarification though. –  Brian Petro Mar 4 '13 at 11:57
add comment
up vote 2 down vote accepted

To fix, I had to add:

    respond_to :json, :html

and:

    respond_with Entry.all

...to the controller.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.