I have downloaded Angular UI Bootstrap Datepicker
, and I need to access to its controllers for their scopes. But I have absolutely no idea how to do it without editing the code in Datepicker, which I think isn't the way it should be done.
So I have my own app/module, myApp
and I have a controller MyController
, in which I need access to UibDatepickerController
and UibDaypickerController
, which are in ui.bootstrap.datepicker
app/module. And I don't want to change the code in ui.bootstrap.datepicker
module.
This is basically the same problem I posted while ago but I have figured it out a lot I think. (Spent like 50 hours in this one :D)
This solution doesn't work because you can't inject controller like you can inject a service.
Here is kind of my design:
Controller:
function MyCtrl() {
var vm = this;
vm.dt = new Date();
vm.options = {
...
};
vm.refresh = function() {
//returns initialized value all the time (current date)
console.log(vm.dt);
$("#calendar").data("$uibDatepickerController").refreshView();
}
};
angular.module('myApp')
.controller('MyCtrl', MyCtrl);
HTML:
<div ng-controller="CalendarCtrl as calCtrl">
<pre>Selected date is: <em>{{calCtrl.dt | date:'fullDate' }}</em>
</pre>
<div style="display:inline-block">
<div uib-datepicker="" id="calendar" ng-model="calCtrl.dt" datepicker-options="calCtrl.options"></div>
</div>
<button ng-click="calCtrl.refresh()">Refresh</button>
</div>