1
Good afternoon, I’m racking my brain to display the date as the user selects. Example:
select 01 - "From/To" dates appear select 02 - Only "Until" select 03 - Only "From" select 04 - No dates shown
I created an array, with the elements dataInicio and dataFim, setting them "s" or "n" for display, however, I don’t know if this is the right way to do it. Now I need to call on the screen, when the user selects an option, it display as per the rule.
(Note: I am using a date component, which uses a template)
--
Note that in the spt-data-interval component I entered an ng-show="filter.Vigenti.dataInicio==’s' && filter.Vigenti.dataInicio==’s'"
It is possible to treat the other rules by ng-show itself?
Follows 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>
If the answer has met you, do not forget to mark it as chosen so that it can be used by someone with similar doubt in the future.
– Sorack