I am receiving a JSON data from backend like these
{
"data":{
"xyz":[
{
"number":"1",
"short_text":"Vertrag unterzeichnen",
"long_text":"Nach Vertrabsunterzeichnung Namen eintragen",
"is_photo":false
},
{
"number":"2",
"short_text":"HR unterrichten",
"long_text":"HR hat eigene Workflows",
"is_photo":true
}
]
}
}
And in the html i am populating a form by ng-repeat
<tr data-ng-repeat="choice in choices track by $index">
<td>{{choice.number}}</td>
<td><p>{{choice.short_text}}</p></td>
<td><input type="textbox" size="50" class="des-textinput" ng-model="choice.desc" required></td>
<td><input type="checkbox" ng-model="choice.include"></td>
<td><input type="file" id="abc{{$index}}" class="photo-upload"
file-model="pic{{$index}}" accept="image/*">
</td>
</tr>
Now I want to make the input type file required if the value of is_photo
is true
in the JSON I am receiving. For each row if the value if is_photo
is false
then it will be not required.
From the given JSON the condition will be the first input type file will be not required as first row is_photo
is false
, but the second one will be required as the value of is_photo
is true
.
How will I do that?