2013-05-31 3 views
0

새로운 고객을 구한 후에 위치를 변경하는 데 문제가 있습니다.
여기 내 컨트롤러가 있습니다.AngularJs가 저장 후 위치를 변경합니다.

function CustomersNewController($scope, $location, Customer) { 
    $scope.selected_customer = ''; 

    $scope.submit = function() { 
    rails_customer = new Customer({customer: $scope.new_customer}); 
    rails_customer.$save({format: 'json'},function(data, getResponseHeaders) { 
     $location.path(data.id + '/edit/') ; 
    }, function(data, getResponseHeaders) { 
     console.log("ERROR"); 
    }); 
    }; 
} 

고객이 데이터베이스에 정상적으로 저장합니다. 문제는 편집 페이지로 리디렉션하기 위해 방금 저장 한 객체의 ID를 가져올 수 없다는 것입니다.

'데이터'개체가 채워집니다하지만 다음과 같습니다

b {customer: Object, $then: function, $resolved: true, $get: function, $save: function…} 
$resolved: true 
$then: function (callback, errback) { 
customer: Object 

사람이 나에게 반환 된 데이터에서 ID를 발굴하는 방법에 손을 줄 수 있습니까?

감사합니다. 데이터에 따르면

답변

0

$location.path(data.customer.id + '/edit'); 
+0

도현해야한다 반대! 그것이 내가 오전 1시에 코딩 할 때 얻는 것입니다! 감사! – jacklin

관련 문제