@@ -641,6 +641,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
641
641
var Attributes = function ( element , attr ) {
642
642
this . $$element = element ;
643
643
this . $attr = attr || { } ;
644
+ this . $$allOrNothingAttr = { } ;
644
645
} ;
645
646
646
647
Attributes . prototype = {
@@ -768,6 +769,22 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
768
769
} ) ;
769
770
} ,
770
771
772
+ /**
773
+ * @ngdoc method
774
+ * @name $compile.directive.Attributes#$setAllOrNothing
775
+ * @function
776
+ *
777
+ * @description
778
+ * Changes the behavior of an interpolated attribute to use "all or nothing" mode.
779
+ *
780
+ * This means that the attribute's interpolated value is `undefined` unless all
781
+ * interpolated expressions are defined.
782
+ *
783
+ * @param {string } key Normalized key. (ie ngAttribute) .
784
+ */
785
+ $setAllOrNothing : function ( key ) {
786
+ this . $$allOrNothingAttr [ key ] = true ;
787
+ } ,
771
788
772
789
/**
773
790
* @ngdoc method
@@ -1865,11 +1882,13 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
1865
1882
// initialize attr object so that it's ready in case we need the value for isolate
1866
1883
// scope initialization, otherwise the value would not be available from isolate
1867
1884
// directive's linking fn during linking phase
1868
- attr [ name ] = interpolateFn ( scope ) ;
1885
+ attr [ name ] = interpolateFn ( scope , attr . $$allOrNothingAttr [ name ] ) ;
1869
1886
1870
1887
( $$observers [ name ] || ( $$observers [ name ] = [ ] ) ) . $$inter = true ;
1871
1888
( attr . $$observers && attr . $$observers [ name ] . $$scope || scope ) .
1872
- $watch ( interpolateFn , function interpolateFnWatchAction ( newValue , oldValue ) {
1889
+ $watch ( function ( scope ) {
1890
+ return interpolateFn ( scope , attr . $$allOrNothingAttr [ name ] ) ;
1891
+ } , function interpolateFnWatchAction ( newValue , oldValue ) {
1873
1892
//special case for class attribute addition + removal
1874
1893
//so that class changes can tap into the animation
1875
1894
//hooks provided by the $animate service. Be sure to
0 commit comments