AngularJs json-formatter json 属性作为作用域变量

AngularJs json-formatter json attribute as scope variable

我正在尝试使用 json-formatter 在其中一个视图中显示 json。

在控制器中,我正在使用通过 rest API 请求模式的服务。请求完成后,结果将分配给范围变量。下面的代码片段:

.controller('SchemaCtrl', ['$scope', '$routeParams', 'Schema','$log',    function($scope, $routeParams, Schema,$log){
    Schema.show($routeParams.name).then(function(schema){
        $scope.schema = schema;
        $scope.schemaShow = true;
    });

在视图中我有下一个代码:

{{schema}}
<div>
    <json-formatter open="1" json="{{schema}}"></json-formatter>
</div>

不幸的是,在 运行 示例之后我收到了下一个错误:

Error: [$parse:syntax] Syntax Error: Token '{' invalid key at column 2 of the expression [{{schema}}] starting at [{schema}}].
{{schema}}

我知道问题是由 json-formatter 引起的。在 angular 将 {{schema}} 替换为适当的值之前解释指令。我如何使用 json-formatter 来通过作用域变量传递值?

顺便说一句。 当我使用硬编码 json 值时,一切正常。

jsonjson-formatter中是2向绑定,所以这里不需要插值标记{{}}

<div>
    <json-formatter open="1" json="schema"></json-formatter>
</div>