I am attempting to display JSON data in a view using the json-formatter plugin.
Within the controller, I'm utilizing a service to make a REST API call for a schema. Once the request is complete, the result is stored in a scope variable. Here's a snippet of the code:
.controller('SchemaCtrl', ['$scope', '$routeParams', 'Schema','$log', function($scope, $routeParams, Schema,$log){
Schema.show($routeParams.name).then(function(schema){
$scope.schema = schema;
$scope.schemaShow = true;
});
In the view, my code looks like this:
{{schema}}
<div>
<json-formatter open="1" json="{{schema}}"></json-formatter>
</div>
Unfortunately, when running the example, I encounter the following error:
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{schema}}] starting at [{schema}}].
{{schema}}
I understand that the issue stems from the way the json-formatter directive processes data before Angular replaces {{schema}}
with the correct value. How can I properly pass values through scope variables while using the json-formatter plugin?
By the way, Using hardcoded JSON works without any issues.