Good afternoon, I'm breaking my head to display the date as per the user's selection. Example:
select 01 - the "From / To" select 02 - Only "To" select 03 - Only "From" select 04 - No dates appear
I've created an array, with the dataInitial and dataFim elements, setting them to "s" or "n" for display, but I do not know if that's the right way to do it. Now I need to call the screen, when the user selects an option, it displays according to the rule.
(Note: I am using a date component, which uses a template)
-
Note that in the spt-data-interval component I have inserted a ng-show="home.source-filter.source == 's &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Can the other rules be handled by the ng-show itself?
Follow the code:
HTML
<div class="form-group">
<label for="" class="col-md-2 control-label">Tipo:</label>
<div class="col-md-4">
<select
class="form-control"
ng-model="filtro.Vigencia"
ng-options="tipoVigencia.nome for tipoVigencia in tipoVigencia"
ng-change="" required>
<option value="">Selecione o Tipo</option>>
</select>
</div>
<spt-data-intervalo
ng-show="filtro.Vigencia.dataInicio=='s' && filtro.Vigencia.dataInicio=='s'"
template-url="inline"
inicio="inicioVigencia"
label-data-inicio="Vigência de:*"
classe-label="col-md-2"
fim="fimVigencia"
label-data-fim="Até:">
</spt-data-intervalo>
</div>
Control
$scope.tipoVigencia=[
{nome: 'select 01', dataInicio:'s', dataFim:'s'},
{nome: 'select 02',dataInicio:'n', dataFim:'s'},
{nome: 'select 03',dataInicio:'s', dataFim:'n'},
{nome: 'select 04',dataInicio:'n', dataFim:'s'},
{nome: 'select 05',dataInicio:'n', dataFim:'n'}
];
Template Data
<div>
<label for="inicio" class="float-left control-label" ng-bind="labelDataInicio"></label>
<div class="{{classeLabel}}">
<spt-data id="inicio" model="inicio" maxima="fim" mascara="39/19/9999" placeholder="dd/mm/aaaa" required></spt-data>
</div>
</div>
<div>
<label for="" class="float-left control-label" ng-bind="labelDataFim">Até:*</label>
<div class="{{classeLabel}}">
<spt-data id="fim" model="fim" minima="inicio" mascara="39/19/9999" placeholder="dd/mm/aaaa" required></spt-data>
</div>
</div>