I am working on my first angular project. For better or for worse, I am trying to convert almost all repeatable HTML into directives. I have a requirement to let the user select a time in HH:MM format. So I need to show two SELECT elements. Since I need to give this control at quite a few places, I am trying to convert into a directive.
Directive Template
<div class="filterLabel">{{fieldLabel}}</div>
<select class="FilterDDL" ng-style="{width: selectHhWidthPx + 'px'}">
<option value="none">HH</option>
<option value="8">08</option>
<option value="9">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
</select>
<span>:</span>
<select class="FilterDDL" ng-style="{width: selectHhWidthPx + 'px'}">
<option value="none">MM</option>
<option value="0">00</option>
<option value="30">30</option>
</select>
My expected end result from this directive is to obtain a time value in minutes [(HH * 60 + MM)] for further calculations. However I can't think of a way in which I can get a single ngModel associated with my directive which returns the time in Minutes from the combination of two dropdowns. I read about Link function but can't figure out if I can use it in my scenario. Is it even a good practice to have custom directives span over multiple input elements?