I have a question model and this is the structure:
{
"id": 5,
"description": "Does your site have Facebook?",
"question_category_id": 3
}
Also the question_category structure:
{
"id": 1,
"name": "Network",
"description": "Network"
}
Now I can fetch the whole list of questions from server side with AngularJs.
But I only want to display questions which are belong to category 1 (id=1) in Section 1, questions in category 2(id=2) in Section 2
And I like the view looks like this:
- Network
- Do you have Facebook?
- Do you have Twitter?
- University
- What is your highest degree?
- etc
- etc...
I tried to write a filter :
<ul class="questionsClass">
<li ng-repeat="q in questions | filter:question_category_id = 1">
{{q.description}}
</li>
</ul>
But it doesn't work.
Just cannot figure it out.
So I wonder how to write the js part and html part.
Thank you
Update
Now my html looks like this:
<table class="table table-striped table-bordered table-hover" id="dataTables-example" ng-controller="testControl">
<div ng-repeat="qc in questionsCategories">
<thead>
<tr>
<th colspan="3" class="bg-success">{{qc.name}}</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="q in questions | filter:{question_category_id : qc.id}">
<td class="text-center">{{q.id}}</td>
<td>
<span>{{q.description}}</span>
<a href="#" data-toggle="popover" title="" data-content="{{q.tip}}">
<i class="fa fa-info-circle fa-1x text-primary"></i>
</a>
</td>
<td>
<label class="radio-inline">
<input type="radio" name="optionsRadiosInline" id="optionsRadiosInline1" value="option1">Yes
</label>
<label class="radio-inline">
<input type="radio" name="optionsRadiosInline" id="optionsRadiosInline2" value="option2">No
</label>
</td>
</tr>
</tbody>
</div>
</table>
But what I get is just a list of questions without categories. It looks like this:
- Do you have Facebook?
- Do you have Twitter?
- What is your highest degree?
- etc
Could anyone figure it out?
thank you.
Update 2
filter: {question_category_id : qc.id}
this filter performs "start with" not "equal to" action, which result in questions which are not in category 1,for example, but in category 10, are displayed in category 1 section.
I also tried :
filter: q.question_category_id == qc.id : true
Then only categories get displayed, and questions disappeared.
Now have no idea about what to do next...

|.