feat($interpolate): use custom toString() function if present
Except on Numbers, Dates and Arrays.
Thanks to @danielkrainas for the initial implementation of this feature.
This behavior is consistent with implementations found in other languages such as Ruby, Python,
and CoffeeScript.
http://rubymonk.com/learning/books/1-ruby-primer/chapters/5-strings/lessons/31-string-basics
https://docs.python.org/2/library/stdtypes.html#string-formatting-operations
http://coffeescriptcookbook.com/chapters/strings/interpolation
The commit also exposes a private $$stringify method on the angular global, so that ngMessageFormat
can use the same logic without duplicating it.
Fixes #7317
Closes #8350
Fixes #11406
BREAKING CHANGE:
When converting values to strings, interpolation now uses a custom toString() function on objects
that are not Number, Array or Date (custom means that the `toString` function is not the same as
`Object.prototype.toString`). Otherwise, interpolation uses JSON.stringify() as usual.
Should you have a custom toString() function but still want the output of JSON.stringify(),
migrate as shown in the following examples:
Before:
```html
<span>{{myObject}}</span>
```
After - use the `json` filter to stringify the object:
```html
<span>{{myObject | json}}</span>
``` M
Martin Staffa committed
a5fd2e4c0376676fa317e09a8d8be4966b82cbfe
Parent: 3cda897