How do I apply a filter to user details when selecting a radio button?
*I need to display only the questions of authenticated users on the list page, so I created a plunker example. If the user is authenticated or an admin, I want to filter and show only their questions on the list page.
For instance: In the plunker example, my displayName
is set as Table 1
. When I select the My Question
radio button, only my questions should be displayed.
HTML radio button code:
<input type="radio" name="myquestion" data-ng-model="myquestion.user.displayName" value="myquestion" >
HTML Filter:
ng-repeat="question in questions | filter: myquestion"
**HTML Data:**
<div ng-repeat="question in questions | filter: myquestion">
<small>
Posted on
<span data-ng-bind="question.created | date:'mediumDate'"></span>
<span data-ng-bind="question.user.displayName"></span>
</small>
</div>
Controller Data:
$scope.questions = [
{
"_id": "583433ddc021a5d02949a51b",
"user": {
"_id": "5834336ac021a5d02949a51a",
"displayName": "mani R",
"location": "ICF",
"dob": "1991-10-05T18:30:00.000Z",
"religion": "Christian",
"roles": [
"user"
],
"profileImageURL": "modules/users/client/img/profile/default.png"
},
"__v": 0,
"upvoters": [],
"category": "Moral Ethics",
"content": "Dhoni",
"title": "which batsman is best in the world?",
"created": "2016-11-22T12:02:37.376Z"
},
{
"_id": "582c34b3ff26bd603e1e5383",
"user": {
"_id": "58072aba0f82a61823c434df",
"displayName": "Table 1",
"dob": "1991-10-04T18:30:00.000Z",
"location": "Icf",
"religion": "Hindu",
"roles": [
"admin"
],
"profileImageURL": "./modules/users/client/img/profile/uploads/c756711556ab6864f408697c7a98aedc"
},
...
]
- We attempted to use
, but it didn't function correctly.alt="{{vm.authentication.user.displayName}}"