mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-23 19:40:56 +08:00
feat(input): support constant expressions for ngTrueValue/ngFalseValue
ngTrueValue and ngFalseValue now support parsed expressions which the parser determines to be constant values.
BREAKING CHANGE:
Previously, these attributes would always be treated as strings. However, they are now parsed as
expressions, and will throw if an expression is non-constant.
To convert non-constant strings into constant expressions, simply wrap them in an extra pair of quotes, like so:
<input type="checkbox" ng-model="..." ng-true-value="'truthyValue'">
Closes #8041
Closes #5346
Closes #1199
This commit is contained in:
21
docs/content/error/ngModel/constexpr.ngdoc
Normal file
21
docs/content/error/ngModel/constexpr.ngdoc
Normal file
@@ -0,0 +1,21 @@
|
||||
@ngdoc error
|
||||
@name ngModel:constexpr
|
||||
@fullName Non-Constant Expression
|
||||
@description
|
||||
|
||||
Some attributes used in conjunction with ngModel (such as ngTrueValue or ngFalseValue) will only
|
||||
accept constant expressions.
|
||||
|
||||
Examples using constant expressions include:
|
||||
|
||||
```
|
||||
<input type="checkbox" ng-model="..." ng-true-value="'truthyValue'">
|
||||
<input type="checkbox" ng-model="..." ng-false-value="0">
|
||||
```
|
||||
|
||||
Examples of non-constant expressions include:
|
||||
|
||||
```
|
||||
<input type="checkbox" ng-model="..." ng-true-value="someValue">
|
||||
<input type="checkbox" ng-model="..." ng-false-value="{foo: someScopeValue}">
|
||||
```
|
||||
Reference in New Issue
Block a user