I am facing an issue where I need to connect the bootstrap datepicker to an input field generated by AngularJS.
The typical approach of using jQuery to attach the datepicker doesn't work as expected because the element is not yet available:
$(function () {
$(':input[name=dispense_date]').datepicker();
});
Instead, I have found a workaround by using setInterval to repeatedly check for the element's existence and then attach the datepicker once it is available:
$(function () {
setInterval(function () {
$(':input[name=dispense_date]').datepicker();
}, 200);
});
Although this solution works, it is not the most efficient or elegant way to achieve the desired result. Is there a better method within Angular controllers/modules to execute callbacks after all operations are complete?
Specifically, I need the jQuery code to run after an $http.get() call, but simply placing it inside the .success() function does not work as $apply has not been executed yet.