我试图使用ng-show / ng-hide显示/隐藏必填字段,除非选中输入以显示字段.但是,表单不会提交,因为需要隐藏字段(除非我选择查看隐藏的附加字段的选项).我在必填字段上使用ng-hide的原因是显示仅在需要时可能需要的其他字段.有没有一种方法可以动态更改“隐藏”输入的属性?
例:
Check Me to Show Additional Fields <input type="checkBox" ng-model="checked"> Additional Fields <input type="number" class="form-control" id="inputamount" data-ng-model="itemamount" step="any" required ng-show="checked"/> <input type="text" class="form-control" id="inputlocation" data-ng-model="itemlocation" placeholder="Location" required ng-show="checked"/>