-1

I'm implementing Dale Lotts datetimepicker in my app. I want to change the value of minView dynamically from minute to day. I have tried something like this.

In HTML:

<datetimepicker data-ng-model="dateModel" data-datetimepicker-config="{ dropdownSelector: 'id', minView: 'minute', configureOn:'change' }"/>

In JS:

scope.config = "{ dropdownSelector: 'id', minView: 'day',configureOn:'change' }";

setTimeout(function () {scope.$broadcast('change', scope.config);}, 500);

I want to set minView property as day at one place and minute at another place with this datetimepicker .

Please suggest.

  • what is your desired output? – Lee Jan 29 '19 at 04:33
  • I have used this datepicker at two places. I want minView as day at one place and minute at another place. – Niket Patil Jan 29 '19 at 04:36
  • There is an option configureOn but It is not very clear how to implement it. You can check this issue. https://github.com/dalelotts/angularjs-bootstrap-datetimepicker/issues/8 – Niket Patil Jan 29 '19 at 04:39
  • Have you looked at the code in the demo directory? https://github.com/dalelotts/angularjs-bootstrap-datetimepicker/blob/master/demo/demo-controller.js#L56 and https://github.com/dalelotts/angularjs-bootstrap-datetimepicker/blob/master/demo/demo-controller.js#L107 and https://github.com/dalelotts/angularjs-bootstrap-datetimepicker/blob/master/demo/index.html#L367 – dale.lotts Jan 29 '19 at 04:48
  • @dale.lotts Thank you so much. It worked. – Niket Patil Jan 29 '19 at 05:41

1 Answers1

0

Finally got it to work. Thank you @dale.lotts

in HTML:

<datetimepicker data-ng-model="dateModel" data-datetimepicker-config="config.configureOnConfig"></datetimepicker>

in JS:

$scope.config = {
    configureOnConfig: {
        dropdownSelector: 'id',
        minView: 'minute',
        configureOn: 'config-changed'
    }
};

$scope.changeConfig=function(){
    $scope.config.configureOnConfig.minView = 'day';
    $scope.$broadcast('config-changed');
}

Call $scope.changeConfig function when you need to change the configuration.