I have been searching the web for a way to create and output a JSON-LD object with AngularJS but with no luck.
What I am trying to achieve is to add structured data to my SPA as described for events here:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Event",
"name": "Example Band goes to San Francisco",
"startDate" : "2013-09-14T21:30",
"url" : "http://example.com/tourdates.html",
"location" : {
"@type" : "Place",
"sameAs" : "http://www.hi-dive.com",
"name" : "The Hi-Dive",
"address" : "7 S. Broadway, Denver, CO 80209"
}
}
</script>
https://developers.google.com/structured-data/rich-snippets/events
A simplistic way to do this could be to build the JSON-LD object and output it inside the script tag. But for my knowledge it is not possible/good practice to access scope values within a script tag like this:
<script type="application/ld+json">
{{jsonLdObject}}
</script>
Can anyone help me with a better approach to do this and is it okay to create the JSON-LD object as a usual JSON object?