I'm trying to present json in one of the view using json-formatter.
In controller I am using service that is requesting schema via rest API. When request is completed result is assigned to the scope variable. Code snippet below:
.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 I have next code:
{{schema}}
<div>
<json-formatter open="1" json="{{schema}}"></json-formatter>
</div>
Unfortunatelly after running example I am receiving next error:
Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{schema}}] starting at [{schema}}].
{{schema}}
I know that the problem is caused by json-formatter. Directive is interpreted before angular replace {{schema}}
with proper value. How can I use json-formatter in order to pass values via scope variables?
Btw. When I use hardcoded json value everything is working well.
console.log
'ed theschema