0
I own a md-select
where according to the selected, I create some div’s using ng-if
. These div’s created have in 02 of them equal models (ng-model). Therefore, when you change Md-select to another one that has the same model, the value set in this field will be maintained. I would like to check the possibility of clearing such a model whenever there has been a field change!?
<div ng-if="input.Tipo == 4">
<div class="col-md-8">
<md-input-container>
<label ng-if="input.Descricao">{{ input.Descricao }}</label>
<label ng-if="input.Descricao == undefined"> Data </label>
<md-select ng-model="input.SequenciaTipoData">
<md-option value="1">Dia Atual</md-option>
<md-option value="2">Ontem</md-option>
<md-option value="3">Início do Mês Atual</md-option>
<md-option value="4">Início do Mês Anterior</md-option>
<md-option value="5">Fim do Mês Anterior</md-option>
<md-option value="6">Data Fixa</md-option>
<md-option value="7">Retroagir X Dias</md-option>
</md-select>
</md-input-container><br />
</div>
<div ng-if="input.SequenciaTipoData == 1 || input.SequenciaTipoData == 2">
<div class="col-md-2">
<md-input-container>
<label>Horário</label>
<input type="text" ng-model="input.Valor" ng-pattern="/^(0[0-9]|1[0-9]|2[0-3])(:[0-5][0-9]){2}$/" required>
</md-input-container>
</div>
</div>
<div ng-if="input.SequenciaTipoData == 6">
<div class="col-md-2" >
<md-datepicker ng-model="input.Valor" md-placeholder="informe data" md-current-view="month" md-open-on-focus required></md-datepicker>
</div>
</div>
<div ng-if="input.SequenciaTipoData == 7">
<div class="col-md-2" >
<md-input-container class="md-block" flex-gt-sm>
<label>Quantidade Dias</label>
<input ng-model="input.Valor" maxlength="365" ng-pattern="/^[0-9]*$/" required>
</md-input-container>
</div>
</div>
</div>
Don’t just use it
$scope.$watch
?– Wallace Maxters
@Wallacemaxters I don’t know this property. Would you have an example? Grateful!
– Bruno Souza
It’s for you to create a functionality in the controller to watch a variable change...
– Wallace Maxters
@Wallacemaxters I’m trying to apply in my solution but unsuccessfully so far.
– Bruno Souza