I'm trying to create a service for two sibling directives to speak through.
I've got a from and a to date-time-picker
directive, both of which share the same template and gets set from the template of shiftsController
, based on a few attributes like name
and a combination of yesterday's, today's and tomorrow's date
, depending on which of the two siblings are created.
As mentioned above they are both initiated on shifts.html
, within a shiftsController as vm
<div>
:
<div>
<date-picker ctrl="from"></date-picker>
</div>
<div>
<date-picker ctrl="to"></date-picker>
</div>
However I seem to be getting an error when attempting to require the shiftsController in the directive:
angular.module("datePicker", [])
.directive("datePicker", function () {
function link(scope, element, attrs, controller) {
controller.doSomething();
}
return {
restrict: "E",
scope: {
ctrl: '='
},
link: link,
templateUrl: "app/views/datepicker.html",
require: '^shiftsController'
};
})
I was under the impression (from multiple articles) that this would be the way to go about setting up the communications between sibling directives.