AngularJS Restfull Call to Perl not working correctly

89 views
Skip to first unread message

akuk

unread,
Jun 8, 2015, 4:14:04 AM6/8/15
to ang...@googlegroups.com
Hi 

 I am creating a web application having AngularJS as frontend and Perl as backend. I am using Perl Dancer and I am used to it but AngularJS is new to me. I am trying to make a simple RESTfull call to web app but It is not working. Below is the complete Code

### Angular JS Code ( index.tt )###

<div ng-app="myApp" ng-controller="customersCtrl"> <ul> <li ng-repeat="x in names"> {{ x.Name + ', ' + x.Country }} </li> </ul> </div> <script> var app = angular.module('myApp', []); app.controller('customersCtrl', function($scope, $http) { $http.get("http://localhost:5000/about") .success(function (response) {$scope.names = response.records;}); }); </script>

####

$http Request to "http://localhost:5000/about" is working fine and returning data in JSON format

{"records": { "2":{"City":"México D.F.","Country":"Mexico","Name":"Ana Trujillo Emparedados y helados"}, "1":{"Name":"Alfreds Futterkiste","Country":"Germany","City":"Berlin"} } }

I am getting the blank page. :(


Message has been deleted

Robert STAICU

unread,
Jun 8, 2015, 4:38:28 AM6/8/15
to ang...@googlegroups.com
I've made this plunker: http://plnkr.co/edit/JFhLt70bU4Hwdzux3V96?p=preview
I usually do this. With your data it's working.

I only injected $scope and $http into controller and initialized $scope.names before $http.get()

Only thing it's different is your response from server. I hope you'll solve this.

Have a nice day  

ashutosh kukreti

unread,
Jun 8, 2015, 11:19:08 PM6/8/15
to ang...@googlegroups.com
Hi Robert

Thanks a lot,, 
its perfectly working fine for me... :)

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/-D1TOl2dyFQ/unsubscribe.
To unsubscribe from this group and all its topics, 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.
For more options, visit https://groups.google.com/d/optout.



--
Thanks & Regards,
Ashutosh Kukreti
Reply all
Reply to author
Forward
0 new messages