@@ -1719,10 +1719,12 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1719
1719
pendingDebounce = null ,
1720
1720
ctrl = this ;
1721
1721
1722
+ var parsedNgModelContext = null ;
1723
+
1722
1724
var ngModelGet = function ngModelGet ( ) {
1723
1725
var modelValue = parsedNgModel ( $scope ) ;
1724
1726
if ( ctrl . $options && ctrl . $options . getterSetter && isFunction ( modelValue ) ) {
1725
- modelValue = modelValue ( ) ;
1727
+ modelValue = modelValue . call ( parsedNgModelContext ? parsedNgModelContext ( $scope ) : $scope ) ;
1726
1728
}
1727
1729
return modelValue ;
1728
1730
} ;
@@ -1732,7 +1734,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1732
1734
if ( ctrl . $options && ctrl . $options . getterSetter &&
1733
1735
isFunction ( getterSetter = parsedNgModel ( $scope ) ) ) {
1734
1736
1735
- getterSetter ( ctrl . $modelValue ) ;
1737
+ getterSetter . call ( parsedNgModelContext ? parsedNgModelContext ( $scope ) : $scope , ctrl . $modelValue ) ;
1736
1738
} else {
1737
1739
parsedNgModel . assign ( $scope , ctrl . $modelValue ) ;
1738
1740
}
@@ -1741,7 +1743,12 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
1741
1743
this . $$setOptions = function ( options ) {
1742
1744
ctrl . $options = options ;
1743
1745
1744
- if ( ! parsedNgModel . assign && ( ! options || ! options . getterSetter ) ) {
1746
+ if ( options && options . getterSetter ) {
1747
+ var ngModelContext = $attr . ngModel . match ( / ^ ( .+ ) \. [ \w $ ] + $ / ) ;
1748
+ if ( ngModelContext ) {
1749
+ parsedNgModelContext = $parse ( ngModelContext [ 1 ] ) ;
1750
+ }
1751
+ } else if ( ! parsedNgModel . assign ) {
1745
1752
throw $ngModelMinErr ( 'nonassign' , "Expression '{0}' is non-assignable. Element: {1}" ,
1746
1753
$attr . ngModel , startingTag ( $element ) ) ;
1747
1754
}
0 commit comments