I'm currently experimenting with Angular and I have an issue, I have a set of questions from my API, some of them rely on other ones to be checked as yes when its a radio button question and will have a value in the property called ReliesOnID
.
Once I check yes, the question which relies on the current one being checked needs to show.
I come from a jQuery background so I would do a function passing in the reliesonid
as that will be the question number and do something like $('#question' + reliesonid').show()
.
How can I make the radio buttons show the other question when I click yes as they are in a repeat? Been stuck on this for ages so help is greatly appreciated. Here is my code below:
<div id="question{{question.Number}}" ng-repeat="question in questions" ng-class="question.ReliesOnID == null ? 'here' : 'hidden'">
<div ng-if="question.QuestionTypeID == 3" >
<div class="row">
<div class="col-xs-12">
<h5>{{question.Question}}</h5>
</div>
</div>
<div class="row">
<div class="col-xs-2">
<div class="col-xs-4"></div>
<div class="col-xs-8">
<input type="radio" value="yes" name="{{question.Number}}" /><label>Yes</label>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-2">
<div class="col-xs-4"></div>
<div class="col-xs-8">
<input type="radio" value="no" name="{{question.Number}}" /><label>No</label>
</div>
</div>
</div>
</div>
<div ng-if="question.QuestionTypeID == 1">
<div class="row">
<div class="col-xs-12">
<h5>{{question.Question}}</h5>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<input type="text" class="form-control" />
</div>
</div>
</div>
</div>
EDIT: Data structure is:
{
"Active": true,
"Comments": false,
"DecimalPlaces": 0,
"F": false,
"FP": false,
"Grouped": null,
"ID": 20500,
"Length": false,
"MP": true,
"Multiline": false,
"Number": 45,
"NumericOnly": false,
"Optional": false,
"Question": "How long ago was the treatment?",
"QuestionID": 45,
"QuestionSectionID": 2,
"QuestionTypeID": 2,
"QuestionnaireID": 298,
"ReliesOnAnswer": true,
"ReliesOnID": 44,
"Weight": false
}