@@ -30,7 +30,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootst
3030 self [ key ] = angular . isDefined ( $attrs [ key ] ) ? ( index < 8 ? $interpolate ( $attrs [ key ] ) ( $scope . $parent ) : $scope . $parent . $eval ( $attrs [ key ] ) ) : datepickerConfig [ key ] ;
3131 } ) ;
3232
33- // Watchable attributes
33+ // Watchable date attributes
3434 angular . forEach ( [ 'minDate' , 'maxDate' ] , function ( key ) {
3535 if ( $attrs [ key ] ) {
3636 $scope . $parent . $watch ( $parse ( $attrs [ key ] ) , function ( value ) {
@@ -477,12 +477,24 @@ function ($compile, $parse, $document, $position, dateFilter, dateParser, datepi
477477 } ) ;
478478 }
479479
480- angular . forEach ( [ 'minDate' , 'maxDate' ] , function ( key ) {
480+ scope . watchData = { } ;
481+ angular . forEach ( [ 'minDate' , 'maxDate' , 'datepickerMode' ] , function ( key ) {
481482 if ( attrs [ key ] ) {
482- scope . $parent . $watch ( $parse ( attrs [ key ] ) , function ( value ) {
483- scope [ key ] = value ;
483+ var getAttribute = $parse ( attrs [ key ] ) ;
484+ scope . $parent . $watch ( getAttribute , function ( value ) {
485+ scope . watchData [ key ] = value ;
484486 } ) ;
485- datepickerEl . attr ( cameltoDash ( key ) , key ) ;
487+ datepickerEl . attr ( cameltoDash ( key ) , 'watchData.' + key ) ;
488+
489+ // Propagate changes from datepicker to outside
490+ if ( key === 'datepickerMode' ) {
491+ var setAttribute = getAttribute . assign ;
492+ scope . $watch ( 'watchData.' + key , function ( value , oldvalue ) {
493+ if ( value !== oldvalue ) {
494+ setAttribute ( scope . $parent , value ) ;
495+ }
496+ } ) ;
497+ }
486498 }
487499 } ) ;
488500 if ( attrs . dateDisabled ) {
0 commit comments