2014-11-27 2 views
-1

잘 작동하는 $ expand REST 서비스 (SAP NW Gateway)를 구현했습니다. odata의 $ exapnd를 수행 중이며 Angular를 사용하여 프런트 엔드를 개발하고 있습니다. 내가 페이로드의 자식 결과 세트를 읽을 고군분투Angularjs를 사용하여 REST Json에서 자식 결과 집합을 읽는 방법

는 아래 내가 여기에 $ scope.resultsset = data.d.dresults처럼 읽을 수 있지만, 내 컨트롤러 내 샘플 페이로드

{ 
d: 
{ 
results: 
[1] 
0: 
{ 
__metadata: 
{ 
id: "host:port/sap/opu/odata/sap/MYEXPAND/HeaderDetails('4500077411')" 
uri: "host:port/sap/opu/odata/sap/MYEXPAND/HeaderDetails('4500077411')" 
type: "MYEXPAND.Header" 
} 
- 
CCode: "1042" 
PONumber: "4500077411" 
DocType: "UB" 
NavItem: 
{ 
results: 
[2] 
0: 
{ 
__metadata: 
{ 
id: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00010')" 
uri: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00010')" 
type: "MYEXPAND.Item" 
} 
- 
PoNumber: "4500077411" 
PoItem: "00010" 
Material: "A10001" 
} 
- 
1: 
{ 
__metadata: 
{ 
id: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00020')" 
uri: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00020')" 
type: "MYEXPAND.Item" 
} 
- 
PoNumber: "4500077411" 
PoItem: "00020" 
Material: "E-M-SAMS-Q001-0009" 
} 
- 
- 
} 
- 
} 
- 
- 
} 
- 
} 

입니다 확장 각각의 PONumber 결과에 대해 navitem-results에서 내 자식 데이터를 읽어야합니다. 여기

는, 들여 쓰기 인 Rajesh

감사 날이 정렬

{ 
    d: 
    { 
     results: 
     [1] 
     0: 
     { 
      __metadata: 
      { 
       id: "host:port/sap/opu/odata/sap/MYEXPAND/HeaderDetails('4500077411')" 
       uri: "host:port/sap/opu/odata/sap/MYEXPAND/HeaderDetails('4500077411')" 
       type: "MYEXPAND.Header" 
      } 
      - 
      CCode: "1042" 
      PONumber: "4500077411" 
      DocType: "UB" 
      NavItem: 
      { 
       results: 
       [2] 
       0: 
       { 
        __metadata: 
        { 
         id: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00010')" 
         uri: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00010')" 
         type: "MYEXPAND.Item" 
        } 
        - 
        PoNumber: "4500077411" 
        PoItem: "00010" 
        Material: "A10001" 
       } 
       - 
       1: 
       { 
        __metadata: 
        { 
         id: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00020')" 
         uri: "host:port/sap/opu/odata/sap/MYEXPAND/Items(PoNumber='4500077411',PoItem='00020')" 
         type: "MYEXPAND.Item" 
        } 
        - 
        PoNumber: "4500077411" 
        PoItem: "00020" 
        Material: "E-M-SAMS-Q001-0009" 
       } 
       - 
       - 
      } 
      - 
     } 
     - 
     - 
    } 
    - 
} 

도움이됩니다

+0

들여 쓰기에 대해 들어 본 적이 있습니까? – Biffen

+0

안녕하세요 Biffen, 조언 주셔서 감사합니다 ... 나는 JavaScript 개발자가 아니기 때문에 들여 쓰기에 대해 미리 알지 못해서 ... 솔직히 :) –

+0

그럼 첫 번째 단계는 그걸 도와 줄 수있는 훌륭한 편집기를 만드는 것입니다. – Biffen

답변

0

구글에서 몇 가지를 검색 한 후 내 자신이, 아래 내가

<ul> 
<li ng-repeat="Y in results"> 
<ul> 
<li ng-repeat=" Z in Y.NavItem.results"> 
<b>PO Number </b>: {{Z.PoNumber}} 
<b>PO Item </b>: {{Z.PoItem}} 
<b>Material</b> : {{Z.Material}} 
</li> 
</ul> 
</li> 
</ul> 
금 방법입니다 해결

주셔서 감사합니다. 라제 스

관련 문제