Compile custom directive before ui-bootstrap directive
-
26-12-2019 - |
Question
I'm trying to create my own directive for a datepicker so when the page is opened on a mobile device the input type change to type="date"
and the native datepicker gets displayed instead of the ui-bootstrap datepicker which I still will be showing on desktop.
I want my directive to be compiled first so inside the compile
function of my directive I be able to remove the ui-bootstrap datepicker directive and this one doesn't get compiled.
Is there a way to do this? I already tried setting priority:9999
on my directive but still the ui-bootstrap directive gets compiled first.
I'm trying something like this right now:
<input type="text"
ng-model="model.date"
ng-click="datepicker.open = true"
my-directive
datepicker-popup="{{datepicker.format}}"
datepicker-options="datepicker.options"
is-open="datepicker.open"
min-date="datepicker.minDate">
Solution
An Angular directive priority starts from 0 (meaning the most important). So if you want your directive to be executed first you will need to specify
priority: 0