2014-04-24 2 views
0

Behance.net에서 데이터를 가져 오려고하는데 정보를 얻으려고 할 때 두 가지 문제가 발생합니다.AngularJS로 중첩 된 JSON에 액세스

첫 번째 문제는 프로젝트 설명을 가져 오는 것입니다. ng-bind="project.description"을 호출하여 정보를 얻을 수 있지만 서식 (단락 반환)이 없으므로 서식있는 설명을 가져 오려고합니다. 여기

<div class="col-sm-6"> 
    <h3 ng-bind="project.name"></h3> 
    <p ng-bind="project.modules.text"></p> 

    <h4><i class="fa fa-tags success"></i> Tags</h4> 
    <div class="row"> 
     <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"> 
     <div class="pull-left label label-info" style="margin-right:5px; margin-bottom:10px;" 
       ng-repeat="tag in project.tags" ng-bind="tag"></div> 
     </div> 
    </div> 

가 Behance이 표시되어 JSON 데이터입니다 : 여기

는 HTML입니다

angular.callbacks._0({ 
    "project": { 
    .... 
     "modules": [{ 
      "id": 111549713, 
      "type": "text", 
      "text": "This is the description of the project I am trying to get" 

내가 추측하고있어 내 두 번째 문제는 첫번째와 동일합니다,하지만 여기있다 .

<p style="margin-top:10px;" ng-bind="user.sections.About"></p> 

와 JSON 파일 :

angular.callbacks._1({ 
    "user": { 
     "sections": { 
      "About Me": Description used on the behance website that I am trying to display 

나는이 두 경우를 제외한 모든 정보를 가져올 수 있습니다. 어떤 도움이라도 대단히 감사하겠습니다.

답변

1

첫 번째 문제 :

project.modules 배열, 그래서 대신이 시도 :

<p ng-bind="project.modules[0].text"></p> 

두 번째 문제 : '내 소개'재산

에 공백을 포함 브라켓 표기법을 사용하여 액세스해야합니다.

<p style="margin-top:10px;" ng-bind="user.sections['About Me']"></p> 
+0

당신은 신입니다. 도와 주셔서 정말 감사합니다. – zach57

+0

당신은 환영합니다 :) – tasseKATT