Filter by Object Property in Ng-Repeat – AngularJS

Hey everyone,

Just a quick post on how to filter by a property when using ng-repeat. To start with, we’ll use the following objects:

{
	"regions": [
		{
			"id": "1",
			"postcode": "4700",
			"name": "Rockhampton",
			"description": "One of the major cities in Central Queensland."
		},
		{
			"id": "16",
			"postcode": "4214",
			"name": "Keppel Island",
			"description": "Awesome islands, very few people, heaps of fish beautiful clear water."
		}
	]
}

Then assuming you want to filter by the postcode all you need is the following:

Region

{{region.name}}

Posted

in

, ,

by

Comments

3 responses to “Filter by Object Property in Ng-Repeat – AngularJS”

  1. Manie Avatar

    Thanks! This was the first straight-forward example I came across and worked perfectly.

    Like

  2. Yaron Guez Avatar

    Thanks! This was exactly what I was looking for.

    Like

  3. Dinesh Avatar
    Dinesh

    What change will I need to make if I want to look for multiple postal codes

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

%d bloggers like this: