我有一个包含5种不同产品和属性的表单,我只想在用户从下拉菜单中选择并增加时显示单个产品字段集(1个产品)
$scope.choices = [{id:'choice1'},{id:'choice1'},];
//New element adding function
$scope.addNewChoice = function(){
var newItemNo = $scope.choices.length+1;
$scope.choices.push({'id':'choice'+newItemNo})
}
//Remove an evidence item from the form
$scope.removeChoice = function(){
var lastItem = $scope.choices.length-1;
$scope.choices.splice(lastItem);
}
这就是我制作动态表单字段的方法,但在每行内部都有我的字段集,但我只想在用户选择该产品时显示特定的产品字段集
答案 0 :(得分:0)
在HTML表单域内设置
<fieldset ng-if='showField($index,"item")'>
...........
</fieldset>
$scope.showField = function(index,item){
if($scope.choices[index]['item'] == item){
return true;
}
}