3

I'm new to angular and I'm using angular-bootstrap-datetimepicker, and I want to access its directive attribute data-datetimepicker-config in my controller

<datetimepicker data-ng-model="data.date" data-datetimepicker-config="{ dropdownSelector: '.dropdown-toggle' }"></datetimepicker>

I have a select component which contains values like daily monthly and yearly and I want to change the minView value of my datetimepicker with the select value.

How can I do that ?

rzelek
  • 3,975
  • 1
  • 33
  • 35
azelix
  • 1,257
  • 4
  • 26
  • 50

1 Answers1

1

The documentation states that

you can pass configuration options as a function or an object.

So you should simply define the config object in your scope or controller and then pass it as value of the data-datetimepicker-config attribute. Here's how you could go about it:

$scope.pickerConfig = { dropdownSelector: '.dropdown-toggle' };

Then in your view:

<datetimepicker data-ng-model="data.date" data-datetimepicker-config="pickerConfig"></datetimepicker>

Basically, changes in pickerConfig will be applied to datetimepicker directive. It is as simple as that.

Igwe Kalu
  • 14,286
  • 2
  • 29
  • 39
rzelek
  • 3,975
  • 1
  • 33
  • 35