This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Commit a9fa4d3
committed
feat(ngModelOptions): add getterSetterContext to specify context for getter/setter bindings
Along with getterSetter, allow users to provide an expression via the getterSetterContext option.
This expression is evaluated to determine the context that should be used when invoking the ngModel
as a getter/setter function.
For example, <input ng-model="someObject.value" ng-model-options="{ getterSetter: true }"> would
previously invoke 'someObject.value()' from the global context. Now, users can specify context, like
ng-model-options="{ getterSetter: true, getterSetterContext: 'someObject'}", which would invoke
'someObject.value()' using 'someObject' as the calling context.
If getterSetterContext is not provided, fallback to using the current scope as the context.
Closes #9394
BREAKING CHANGE: previously, getter/setter functions would always be called from the global context.
This behaviour was unexpected by some users, as described in #9394, and is not particularly nice
anyways. Applications that relied on this behaviour can use `$window` instead of `this` to access
the global object... but they probably shouldn't be storing global state anyways!1 parent e69c180 commit a9fa4d3
2 files changed
+85
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1716 | 1716 | | |
1717 | 1717 | | |
1718 | 1718 | | |
| 1719 | + | |
1719 | 1720 | | |
1720 | 1721 | | |
1721 | 1722 | | |
1722 | 1723 | | |
1723 | 1724 | | |
1724 | 1725 | | |
1725 | | - | |
| 1726 | + | |
1726 | 1727 | | |
1727 | 1728 | | |
1728 | 1729 | | |
| |||
1732 | 1733 | | |
1733 | 1734 | | |
1734 | 1735 | | |
1735 | | - | |
| 1736 | + | |
1736 | 1737 | | |
1737 | 1738 | | |
1738 | 1739 | | |
| |||
1741 | 1742 | | |
1742 | 1743 | | |
1743 | 1744 | | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
1744 | 1750 | | |
1745 | 1751 | | |
1746 | 1752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1975 | 1975 | | |
1976 | 1976 | | |
1977 | 1977 | | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
| 2032 | + | |
| 2033 | + | |
| 2034 | + | |
| 2035 | + | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
1978 | 2055 | | |
1979 | 2056 | | |
1980 | 2057 | | |
| |||
0 commit comments