I'm testing out angular for the first time. In javascript I have a json-object. How do I make it available to use in my angular template?
2 Answers
Angular comes with a angular.fromJson(jsonData) method that you can use to transform your JSONdata into a JavaScript object.
See: http://docs.angularjs.org/api/angular.fromJson
Then you just need to expose it on a scope like:
$scope.myData = angular.fromJson(jsonData);
Now you are free to use it in your templates:
<div>{{myData.someProperty}}</div>