2014-10-13 4 views
1

URL을 통해 json 데이터를 가져 오는 데 사용하려고하는 다음 코드가 있습니다. 데이터가 채워지지 않습니다. 내가 어디로 잘못 가고 있니? 내가 여러 옵션을 시도했지만 그들 중 누구도 내베이스 코드와 json URL 데이터를 가져올 필요가 있도록 노력하고 있습니다. 내가Angular.js로 json 데이터 가져 오기

var urvirl = angular.module('urvirl', ['ngRoute', 'ngAnimate', 'ngTouch']). 
config(['$routeProvider', function($routeProvider) { 
$routeProvider. 
    when('/', { 
    templateUrl: 'fragments/homepage.html', 
    controller: 'homepageController' 
    }). 
    when('/security-profile/', { 
    templateUrl: 'fragments/my-account.html', 
    controller: 'securityController' 
    }). 
    otherwise({ 
    redirectTo: '/' 
    }); 
}]); 


var urvirl_controllers = angular.module('urvirl.controllers', ['ngRoute']); 

urvirl_controllers. 
    controller('securityController', ['$scope', '$route', '$window', 
    function ($scope, $route, $window,) { 

    }]); 

에이 코드를 넣어야하고 URL은 여기입니다 보안 컨트롤러는 다음과 같습니다

$http.get('http://ec2-54-68-150-129.us-west-2.compute.amazonaws.com:8080/urvirl-0.0.1-SNAPSHOT/user/5') 
+0

는 .. 오류 콘솔을 확인 우리가 전체 그림을 볼 수 있도록 – tymeJV

+0

는 plunkr 또는 동등한를 확인하시기 바랍니다. –

답변

0

이것은 내가 그 URL로 이동에서 얻을 데이터이었다

{ 
    "id": 0, 
    "userID": null, 
    "firstName": null, 
    "lastName": null, 
    "screenName": null, 
    "mobilePhone": null, 
    "homePhone": null, 
    "workPhone": null, 
    "homeEmail": null, 
    "workEmail": null, 
    "cityLocation": null, 
    "workLocation": null, 
    "countryID": null, 
    "birthDate": null 
} 

서버가 유효한 정보를 반환하지 않는 것처럼 보입니다. 너 어디서 전화하는거야? chrome/firefox/IE의 개발자 도구를 사용하여 서버에 대한 http 호출과 응답 (헤더 및 본문 모두)을 확인하십시오.

0

'urvirl.controllers' 모듈을 다음과 같이 종속성으로 선언해야합니다. 'urvirl' 모듈 :

var urvirl = angular.module('urvirl', ['ngRoute', 'ngAnimate', 'ngTouch','urvirl.controllers']). 
// ... 
+0

나는 이것을 시도했지만 여전히 나에게 같은 오류를 주었다. – hosker