使用AngularJS在我的视图中将json渲染到另一个json中

时间:2014-07-23 19:09:12

标签: javascript json angularjs

我有一个看起来像这样的json,我正在Angular的数据库中读取:

    {"content":"{
  "address": "<p>This is a test</p>",
  "email": "<p><a href='mailto:info@info.com'>info@info.com</a></p>",
  "country": "UK"
    }"}

此数据通过以下方式接收:

var urlData = $resource('http://info.com/admin/get_page/2');
$scope.Data = urlData.get();

在我看来,我需要打印地址和另一封电子邮件,所以我想它应该是这样的:

<article class="contactInfo-group" ng-bind-html="Data.content">
{{ Data.content.address }}
</article>

我怎样才能得到我想要的信息?

1 个答案:

答案 0 :(得分:1)

<article class="contactInfo-group">
{{ Data.content.address }}
</article>}}

json应该是:

 $scope.data = {"content":
                       {
                       "address": "<p>This is a test</p>",
                       "email": "<p><a href='mailto:info@info.com'>info@info.com</a></p>",
                       "country": "UK"
                      }
                        }

看小提琴。      http://jsfiddle.net/micronyks/9DcXA/4/