I am trying to implement ng-if directives based on the values of "male", "female" or "all". However, when using data-ng-show, the values are working fine as true and false for AnswerList2[index][GenderTypeAnswer]. I want to achieve this without displaying the element in the DOM.
var sampleData=[{
"QuestionId": 1,
"Question": "Please tick the box that applies to you",
"AnswerList": [
{
"AnswerId": 1,
"Answer": "Male",
"GenderTypeAnswer": "male"
},
{
"AnswerId": 2,
"Answer": "Female",
"GenderTypeAnswer": "female"
},
{
"AnswerId": 3,
"Answer": "NA",
"GenderTypeAnswer": "all"
}
]
}];
$scope.all=true;
$scope.male=true;
$scope.female=false;
<p data-ng-repeat="(index,value) in sampleData[0]['AnswerList'] as AnswerList2" data-ng-if="AnswerList2[index][GenderTypeAnswer]" data-ng-bind-html="AnswerList2[index]['Answer']"></p>
I have a JSON object with "GenderTypeAnswer" key values that I'm using as scope variables in my JavaScript. However, I'm facing issues retrieving these values in the ng-if directive. Can anyone provide assistance?
That's the crux of it
The value of AnswerListLast[index]['GenderTypeAnswer'] is appearing as-is in ng-if.