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 ,
711
+ attrName : match [ 4 ] || scopeName ,
710
712
mode : match [ 1 ] ,
711
- optional : match [ 2 ] === '?'
713
+ optional : match [ 2 ] === '?' ,
714
+ collection : match [ 3 ] == '*'
712
715
} ;
713
716
} ) ;
714
717
@@ -1894,7 +1897,9 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1894
1897
return lastValue = parentValue ;
1895
1898
} ;
1896
1899
parentValueWatch . $stateful = true ;
1897
- var unwatch = scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal ) ;
1900
+ var unwatch = ! definition . collection
1901
+ ? scope . $watch ( $parse ( attrs [ attrName ] , parentValueWatch ) , null , parentGet . literal )
1902
+ : scope . $watchCollection ( attrs [ attrName ] , parentValueWatch ) ;
1898
1903
isolateScope . $on ( '$destroy' , unwatch ) ;
1899
1904
break ;
1900
1905
0 commit comments