@@ -1715,33 +1715,22 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1715
1715
this . $name = $interpolate ( $attr . name || '' , false ) ( $scope ) ;
1716
1716
1717
1717
1718
- var parsedNgModel = $parse ( $attr . ngModel ) ,
1719
- pendingDebounce = null ,
1718
+ var pendingDebounce = null ,
1720
1719
ctrl = this ;
1721
1720
1722
- var ngModelGet = function ngModelGet ( ) {
1723
- var modelValue = parsedNgModel ( $scope ) ;
1724
- if ( ctrl . $options && ctrl . $options . getterSetter && isFunction ( modelValue ) ) {
1725
- modelValue = modelValue ( ) ;
1726
- }
1727
- return modelValue ;
1728
- } ;
1729
-
1730
- var ngModelSet = function ngModelSet ( newValue ) {
1731
- var getterSetter ;
1732
- if ( ctrl . $options && ctrl . $options . getterSetter &&
1733
- isFunction ( getterSetter = parsedNgModel ( $scope ) ) ) {
1734
-
1735
- getterSetter ( ctrl . $modelValue ) ;
1736
- } else {
1737
- parsedNgModel . assign ( $scope , ctrl . $modelValue ) ;
1738
- }
1739
- } ;
1721
+ var ngModelGet = $parse ( $attr . ngModel ) ;
1722
+ var ngModelSet = ngModelGet . assign ;
1740
1723
1741
1724
this . $$setOptions = function ( options ) {
1742
1725
ctrl . $options = options ;
1743
1726
1744
- if ( ! parsedNgModel . assign && ( ! options || ! options . getterSetter ) ) {
1727
+ if ( options && options . getterSetter ) {
1728
+ ngModelGet = $parse ( $attr . ngModel + "()" ) ;
1729
+ var ngModelSetInvoke = $parse ( $attr . ngModel + "($$ngModelValue)" ) ;
1730
+ ngModelSet = function ( $scope , value ) {
1731
+ ngModelSetInvoke ( $scope , { $$ngModelValue : value } ) ;
1732
+ } ;
1733
+ } else if ( ! ngModelSet ) {
1745
1734
throw $ngModelMinErr ( 'nonassign' , "Expression '{0}' is non-assignable. Element: {1}" ,
1746
1735
$attr . ngModel , startingTag ( $element ) ) ;
1747
1736
}
@@ -2103,7 +2092,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
2103
2092
}
2104
2093
if ( isNumber ( ctrl . $modelValue ) && isNaN ( ctrl . $modelValue ) ) {
2105
2094
// ctrl.$modelValue has not been touched yet...
2106
- ctrl . $modelValue = ngModelGet ( ) ;
2095
+ ctrl . $modelValue = ngModelGet ( $scope ) ;
2107
2096
}
2108
2097
var prevModelValue = ctrl . $modelValue ;
2109
2098
var allowInvalid = ctrl . $options && ctrl . $options . allowInvalid ;
@@ -2130,7 +2119,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
2130
2119
} ;
2131
2120
2132
2121
this . $$writeModelToScope = function ( ) {
2133
- ngModelSet ( ctrl . $modelValue ) ;
2122
+ ngModelSet ( $scope , ctrl . $modelValue ) ;
2134
2123
forEach ( ctrl . $viewChangeListeners , function ( listener ) {
2135
2124
try {
2136
2125
listener ( ) ;
@@ -2226,7 +2215,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
2226
2215
// ng-change executes in apply phase
2227
2216
// 4. view should be changed back to 'a'
2228
2217
$scope . $watch ( function ngModelWatch ( ) {
2229
- var modelValue = ngModelGet ( ) ;
2218
+ var modelValue = ngModelGet ( $scope ) ;
2230
2219
2231
2220
// if scope model value and ngModel value are out of sync
2232
2221
// TODO(perf): why not move this to the action fn?
0 commit comments