Not able to receive the json response

78 views
Skip to first unread message

Loganathan Sellappa

unread,
Feb 10, 2013, 3:07:06 PM2/10/13
to ang...@googlegroups.com
HI All,

I am new to Angular js and while integrating the Angular js with my Ruby on Rails application, but I am not able to receive the json response via $scope, copied below my codebase for your reference anybody's help would be really appreciated.

JS code:

app = angular.module('Entry', ['ngResource'])
function ListCtrl($scope, $resource) {
  BlogEnrty = $resource("/blog_entries.json")
  $scope.blog_entries = BlogEnrty.query();
}

HTML:

<html ng-app="Entry">
<div ng-controller='ListCtrl'>
 <table>
   <tr  ng-repeat= "entry in entries">
    {{entry.title}}
   </tr>
  </table>
</div>
</html>

Error:
[{"content":"Andy Dufresne is a young and successful banker whose life changes drastically when he is convicted and sentenced to life imprisonment for the murder of his wife and her lover. Set in the 1940's, the film shows how Andy, with the help of his friend Red, the prison entrepreneur, turns out to be a most unconventional prisoner.","created_at":"2013-02-03T10:54:44Z","id":1,"title":"The Shawshank Redemption","updated_at":"2013-02-03T10:54:44Z","user_id":1}]


Regards,
Logan

Joshua Miller

unread,
Feb 10, 2013, 3:11:16 PM2/10/13
to angular
Hello!

I think there are a few typos in your code (e.g. 'entries' instead of 'blog_entries', 'BlogEnrty' instead of 'BlogEntry'), but nothing that would cause that error. Can you post a plunker or fiddle that shows the problem?

Josh


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Loganathan Sellapa

unread,
Feb 10, 2013, 3:13:00 PM2/10/13
to ang...@googlegroups.com
I tested with blog_entries too, but no luck.

<table>
  <tr  ng-repeat= "entry in blog_entries">
   {{entry.title}}
  </tr>
  </table>


regards,
Loganathan
Mob: +91 7760780741 | +91 9944414388
Skype: loganathan.sellappa
ViewMe

Joshua Miller

unread,
Feb 10, 2013, 3:45:36 PM2/10/13
to angular
That error shouldn't occur from your code - I'll bet the code you posted is not what caused it. Can you post a plunker or fiddle demonstrating the error? If you've never created one before, Pawel's post will help: http://pkozlowskios.wordpress.com/2012/08/12/using-jsfiddle-with-angularjs/

Josh

Loganathan Sellapa

unread,
Feb 10, 2013, 3:47:37 PM2/10/13
to angular
HI Josh,


regards,
Loganathan
Mob: +91 7760780741 | +91 9944414388
Skype: loganathan.sellappa
ViewMe



Joshua Miller

unread,
Feb 10, 2013, 3:59:08 PM2/10/13
to angular
Thanks.

Okay, Firebug showed you were missing ngResource, so I added it. Now, nothing showed because you didn't use a "td" in your "tr"; fixing that, your data shows, but I don't get the $digest error. So I mocked the backend so the call would actually use $resource, and it still works with no $digest error: http://plnkr.co/edit/GTmrMK?p=preview.

Can you start with the modified Plunker and continue adding your original code until it errors out? That's probably the easiest way to discover the problem.

Josh
Reply all
Reply to author
Forward
0 new messages