我在中继器中有一个下拉列表,该列表应切换我的自定义“必需”属性。我尝试了ng-show,但是display =“ none”属性已添加。我的选择是:
1-添加/删除输入字段并设置bird.Stuff,不仅是隐藏它,因为它仍然是必需的。
2-在输入字段上添加/删除“必需”属性。
js
$scope.validateParticipants = function (type) {
if (type == "Single") {
this.donation.Participants = "1";
}
else
this.donation.Participants = "";
}
html
<div ng-repeat="bird in animalTest.birds">
@(Html.DropDownList("Type", (IEnumerable<SelectListItem>)ViewBag.BirdList, new { ng_model = "bird.Type", ng_change = "validateRequired(bird.Type)", required = "Type is required" }))
...
<input data-ng-show="bird.Type == 'Endangered'" id="stuff" type="number" data-ng-model="bird.Stuff" required = "Number of Volunteers required"/>
</div>
我在这里先向您的帮助表示感谢!
使用ng-required。这将采用一个角度表达式,并在表达式为true时添加所需的属性。
<input type="number" data-ng-model="bird.Stuff" ng-required="donation.Participants > 0"/>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句