2017-09-20 4 views
0

anglejsのキー値のペアに基づいてjsonオブジェクトから特定のデータをフェッチできません。anglejsのキー値ペアに基づいてjsonオブジェクトから特定のデータをフェッチできません

var app = angular.module("myApp", []); 
    app.controller("myDialogController", function($http, $scope) { 
     alert("nishant is here"); 

     $scope.onSubmit = function() { 
      alert("inside submit function"); 
     } 

     $scope.displayData = function() { 
      alert("nishant is here on load"); 
     } 
    }); 

    app.controller("myCntrl", function($scope, $http) { 
     alert("velson is here"); 
     $scope.displayData = function() { 
      alert("inside the velson"); 
      $http.get("retrieve_1.jsp") 
       .then(function(response) { 
        $scope.name = response.data; 
        //$scope.value = $scope.name.id; 
        //alert($scope.value); 


       }); 
     } 
    }) 

はここで$ scope.nameは含まれています

[{"id":"1","emp_id":"2010","sales_force_id":"sales_force_id_test_url","type_of_request":"New","rfp_rfi":"1","closure_deadline":"2017-09-18 15:23:37.0","mode_of_submission":"S","submission_date":"2017-09-18 15:23:37.0","clarification_date":"2017-09-18 15:23:37.0","extention_date":"2017-09-18 15:23:37.0","region":"Region 1","item_status":"Pending","participants_status":"Pending","reviewer_status":"Pending","description":"null","bid_owner":"null"}] 

しかし、私はこのことから、IDを取得することはできませんよ。私を助けてください。

答えて

0

$scope.nameは、オブジェクト

のリストフェッチの通りです:

リストを取得し、それはあなたのために明らかになりますので、 $scope.names$scope.nameをリファクタリングする価値も
$scope.value = $scope.name[0].id; 

$scope.names = response.data; 
$scope.value = $scope.names[0].id; 
0

あなたは= $ scope.name [0] .ID

0

が、これは

var myApp = angular.module('myApp',[]); 
 

 
function MyCtrl($scope) { 
 
    $scope.data = [{"id":"1","emp_id":"2010","sales_force_id":"sales_force_id_test_url","type_of_request":"New","rfp_rfi":"1","closure_deadline":"2017-09-18 15:23:37.0","mode_of_submission":"S","submission_date":"2017-09-18 15:23:37.0","clarification_date":"2017-09-18 15:23:37.0","extention_date":"2017-09-18 15:23:37.0","region":"Region 1","item_status":"Pending","participants_status":"Pending","reviewer_status":"Pending","description":"null","bid_owner":"null"}]; 
 
}
table, th, td { 
 
    border: 1px solid black; 
 
    border-collapse: collapse; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div ng-app="myApp" ng-controller="MyCtrl"> 
 
    <table borderd> 
 
    <tr> 
 
    <th>Id</th> 
 
    <th>Emp Id</th> 
 
    <th>Sales Force Id</th> 
 
    <th>Item Status</th> 
 
    </tr> 
 
    <tr ng-repeat="i in data"> 
 
    <td>{{i.id}}</td> 
 
    <td>{{i.emp_id}}</td> 
 
    <td>{{i.sales_force_id}}</td> 
 
    <td>{{i.item_status}}</td> 
 
    </tr> 
 
</table> 
 
</div>

月、このことができます試してみてください。この VaRのIDのようなID値を取得することができますあなた

関連する問題