0

I have a json that looks like this that I'm reading from my database in Angular:

    {"content":"{
  "address": "<p>This is a test</p>",
  "email": "<p><a href='mailto:[email protected]'>[email protected]</a></p>",
  "country": "UK"
    }"}

This data is received through:

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

In my view there's a place where I need to print just the address and another the email, so I would imagine it should be something like this:

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

How could I get the info I want there?

0

1 Answer 1

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

json should be:

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

see fiddle. http://jsfiddle.net/micronyks/9DcXA/4/

Sign up to request clarification or add additional context in comments.

2 Comments

The problem is that urlData.get() saves me a 'Resource' in Data instead of an 'Object' like in your case and it doesn't print anything when using Data.content.address
Nevermind, I was doing it right, but the backend was serving a wrong JSON -.-

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.