164
164
* value of `parentModel` on the parent scope. Any changes to `parentModel` will be reflected
165
165
* in `localModel` and any changes in `localModel` will reflect in `parentModel`. If the parent
166
166
* scope property doesn't exist, it will throw a NON_ASSIGNABLE_MODEL_EXPRESSION exception. You
167
- * can avoid this behavior using `=?` or `=?attr` in order to flag the property as optional.
167
+ * can avoid this behavior using `=?` or `=?attr` in order to flag the property as optional. If
168
+ * you want to shallow watch for changes (i.e. $watchCollection instead of $watch) you can use
169
+ * `=*` or `=*attr` (`=*?` or `=*?attr` if the property is optional).
168
170
*
169
171
* * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope.
170
172
* If no `attr` name is specified then the attribute name is assumed to be the same as the
@@ -691,7 +693,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
691
693
var EVENT_HANDLER_ATTR_REGEXP = / ^ ( o n [ a - z ] + | f o r m a c t i o n ) $ / ;
692
694
693
695
function parseIsolateBindings ( scope , directiveName ) {
694
- var LOCAL_REGEXP = / ^ \s * ( [ @ = & ] ) ( \? ? ) \s * ( \w * ) \s * $ / ;
696
+ var LOCAL_REGEXP = / ^ \s * ( [ @ & ] | = ( \* ? ) ) ( \? ? ) \s * ( \w * ) \s * $ / ;
695
697
696
698
var bindings = { } ;
697
699
@@ -706,9 +708,10 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
706
708
}
707
709
708
710
bindings [ scopeName ] = {
709
- attrName : match [ 3 ] || scopeName ,
710
- mode : match [ 1 ] ,
711
- optional : match [ 2 ] === '?'
711
+ mode : match [ 1 ] [ 0 ] ,
712
+ collection : match [ 2 ] === '*' ,
713
+ optional : match [ 3 ] === '?' ,
714
+ attrName : match [ 4 ] || scopeName
712
715
} ;
713
716
} ) ;
714
717
@@ -1890,7 +1893,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1890
1893
return lastValue = parentValue ;
1891
1894
} ;
1892
1895
parentValueWatch . $stateful = true ;
1893
- var unwatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
1896
+ var unwatch ;
1897
+ if ( definition . collection ) {
1898
+ unwatch = scope . $watchCollection ( attrs [ attrName ] , parentValueWatch ) ;
1899
+ } else {
1900
+ unwatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
1901
+ }
1894
1902
isolateScope . $on ( '$destroy' , unwatch ) ;
1895
1903
break ;
1896
1904
0 commit comments