Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 6171372

Browse files
jrvidalpetebacondarwin
authored andcommitted
docs($resource): document Resource#toJSON
Document the `toJSON` method of `Resource` instances as part of its public API. See #14637 Closes #14725
1 parent 71b966a commit 6171372

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ngResource/resource.js

+8
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,14 @@ function shallowClearAndCopy(src, dst) {
265265
* - `$cancelRequest`: If there is a cancellable, pending request related to the instance or
266266
* collection, calling this method will abort the request.
267267
*
268+
* The Resource instances have these additional methods:
269+
*
270+
* - `toJSON`: It returns a simple object without any of the extra properties added as part of
271+
* the Resource API. This object can be serialized through {@link angular.toJson} safely
272+
* without attaching Angular-specific fields. Notice that `JSON.stringify` (and
273+
* `angular.toJson`) automatically use this method when serializing a Resource instance
274+
* (see [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior)).
275+
*
268276
* @example
269277
*
270278
* # Credit card resource

0 commit comments

Comments
 (0)