我正在尝试根据在 Select 中选择的内容显示/隐藏输入,但我不能
HTML
<section class="row nm">
<div class="column g-12 nbp denunciaMsg">
<mm-msg description="{{apResumenHogar.msgText}}" type="info" title="">
</div>
<div>
<div class="column g-6 fg twoFieldRow">
<select ng-class="{'likePlaceholder': !resumenVidaCtrl.comboVal}" ng-model="resumenVidaCtrl.comboVal" style="width: 80%;">
<option value="{{item.codigo}}" ng-repeat="item in resumenVidaCtrl.masterTipoBeneficiario">{{item.descripcion}}</option>
</select>
</div>
<div class="wrapInput beneficiario" ng-if="resumenVidaCtrl.contratacionData.beneficiarios[0].codigo === 'O'">
<input type="text" maxlength="320" name="otrosBeneficiarios" id="otrosBeneficiarios" ng-model="resumenVidaCtrl.textoBeneficiarios" placeholder="Indica Nombre y DNI de los beneficiarios">
<label><span class="help">Si hay más de un beneficiario sepáralos con una coma (,). Ej. Juan López Pérez 50123456Z, José Domínguez López 50234567X.<br/>También puedes designar beneficiarios con un texto libre Ej. Mis hijos.</span></label>
</div>
</div>
</section>
在选择选项中,值为1、2、3、0,如果我选择选项0,则应出现输入。不知道是用ng-if、ng-show还是ng-hide更方便。
AngularJS
function continuar () {
$rootScope.respuesta = false;
if (vm.contratacionData.beneficiarios[0].codigo === 'O') {
}
}
老实说,我不知道如何执行 if 来显示输入,我一直在尝试从互联网上获取的几个示例,但什么也没有,或者它仍然没有显示给我,或者它给了我一个错误并且它没有加载窗口中的任何数据。
您能否帮助我或给我一些指导方针以创建在选择中选择选项时显示或隐藏输入的功能?
非常感谢
想象一下,您在 HTML 中创建了一个输入;如果您
ng-show/ng-hide
用来显示或隐藏所述元素,它会毫无问题地做到这一点,并且 -这是与 ng-if 的区别- 它将始终存在于 DOM中;如果你使用它来显示它,如果它满足(或不)你给它的条件ng-if
,这个输入将被创建或从 DOM 中删除。这应该适合你: