Home Ask Login Register

Developers Planet

Your answer is one click away!

ChrisM February 2016

Angular - Filtering an ng-repeat by Item.User._id

Im trying to filter an ng-repeat by an id value.

$scope.filter = $stateParams.id;  --> 56a1832a36dc3d0e00c7aa3f

Heres the model for the Item Object with relevant vlues

var ItemSchema = new Schema({

  title: {
    type: String,
    maxlength: 150
  user: {
    type: Schema.ObjectId,
    ref: 'User'


How exactly do i filter the Items by the user._id ?

My attempt which is giving no results.

<div ng-repeat="saving in savings| filter: {user : 'filter'}">


Július Retzer February 2016


The docs explain using filters very well. The filter filters the array by property you pass to it. If it's an object, it will match its properties against each item in the array. This means that item in array with property user: {_id: 2} will be shown.

<div ng-repeat="saving in savings | filter:{user: {_id: 2}}">{{saving.title}}</div>

You can checkout this question for another example.

Post Status

Asked in February 2016
Viewed 3,557 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life