Improve this Doc View Source json

From Get docs
< Filter components in ngAngularjs/docs/1.8/api/ng/filter/json


Improve this Doc View Source json

  1. filter in module ng

Overview

Allows you to convert a JavaScript object into JSON string.

This filter is mostly useful for debugging. When using the double curly Template:Value notation the binding is automatically converted to JSON.


Usage

In HTML Template Binding

{{ json_expression | json : spacing}}

In JavaScript

$filter('json')(object, spacing)

Arguments

Param Type Details
object * Any JavaScript object (including arrays and primitive types) to filter.

spacing

(optional)

number The number of spaces to use per indentation, defaults to 2.


Returns

string JSON string.

Example

© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 3.0.
https://code.angularjs.org/1.8.2/docs/api/ng/filter/json