angular-ui/bootstrap — pull request #1915 by Foxandxss (2014-03-10 15:41:55+00:00)
Title: refactor(datepicker): use ng-if to increase performance

It is going to be fun, someone said. Damn, I never felt this much pain on a refactor.

Adding an extra scope in the middle of this directive was way problematic.

Adding that ng-if needed to modify all the popup tests to manually open the datepicker (earlier, you could run your tests vs a hidden datepicker but not if it is not there).

On the other hand, I needed to use the `dot.rule` for the date so it would work as expected.

On the `$destroy` `$popup` is the comment of the ng-if, so you have to destroy the sibling element.

What I am not happy about is the close button. Since there is a new parent scope, you need an extra `$parent`. Can I use there the `dot.rule`? Sure but that would need an extra $watch.

Let me explain: If I change everything like: s/scope.isOpen/scope.popup.isOpen/ it would work, but I still need to `$watch` if the `isOpen` changed outside.

Said this. Feel free to review it and suggest changes.