$parseProvider
can be used for configuring the default behavior of the $parse service.
$parseProvider();
This feature is deprecated, see deprecation notes below for more info
If set to true (default is false), $parse will unwrap promises automatically when a promise is found at any part of the expression. In other words, if set to true, the expression will always result in a non-promise value.
While the promise is unresolved, it's treated as undefined, but once resolved and fulfilled, the fulfillment value is used in place of the promise while evaluating the expression.
Deprecation notice
This is a feature that didn't prove to be wildly useful or popular, primarily because of the dichotomy between data access in templates (accessed as raw values) and controller code (accessed as promises).
In most code we ended up resolving promises manually in controllers anyway and thus unifying the model access there.
Other downsides of automatic promise unwrapping:
Warning Logs
If the unwrapping is enabled, Angular will log a warning about each expression that unwraps a promise (to reduce the noise, each expression is logged only once). To disable this logging use $parseProvider.logPromiseWarnings(false)
api.
Param | Type | Details |
---|---|---|
value (optional) | boolean | New value. |
boolean self
|
Returns the current setting when used as getter and self if used as setter. |
Controls whether Angular should log a warning on any encounter of a promise in an expression.
The default is set to true
.
This setting applies only if $parseProvider.unwrapPromises
setting is set to true as well.
Param | Type | Details |
---|---|---|
value (optional) | boolean | New value. |
boolean self
|
Returns the current setting when used as getter and self if used as setter. |
© 2010–2016 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://code.angularjs.org/1.2.32/docs/api/ng/provider/$parseProvider