diosney / angular-bootstrap-datetimepicker-directive

A wrapper directive around the bootstrap-datetimepicker component.
MIT License
69 stars 50 forks source link

The isolate scope prevents the directive from correctly reading the options from the scope #3

Open lucipacurar opened 9 years ago

lucipacurar commented 9 years ago

Hi,

Sorry about the long title, but creating an isolated scope prevents scope.$eval() from getting the options from the controller scope. You can safely remove the isolated scope.

diosney commented 9 years ago

Sorry for the delay, I was busy on other projects.

Can you post an example to check it? I tested on the example.html file and worked correctly.

lucipacurar commented 9 years ago

No worries :)

scope : { datetimepickerOptions: '@' }

This means that inside the HTML you MUST interpolate the object datetimepicker-options="{{ myScopeOptions }}" and serialize it inside the DOM attribute.

I think it's better to have it evaluated as an expression (&) inside the isolated scope, bidirectionally bound (=) if you try to change the options after the datepicker has been initialized, or even remove the isolated scope altogether since it's not needed right now.

This is more of a design preference, not an issue :) I realized how the directive works after looking through the code. I was simply using datetimepicker-options="myScopeOptions" and that didn't work with scope.$eval.