0

Hi I have a json array like this

var homes = [
    {

        "city": "Dallas",
        "state": "TX",
        "zip": "75201",
        "NoteNumber": "162500"
    }, {

        "city": "Bevery Hills",
        "state": "CA",
        "zip": "90210",
        "NoteNumber": "319250"
    }, {

        "city": "New York",
        "state": "NY",
        "zip": "00010",
        "NoteNumber": "null"
    }
];

I am displaying them in a div using ng-repeat

<div ng-repeat="name in homes">
{{name.city}}
</div>

I have html select tag with options notenumber and null

Help me how to show cities who only have notenumber when notenumber is selected and when null is selected it should show only null notenumber cities.

1
  • 1
    you can generate select tag with use of ng-options and addign current value to ng-model in select tag. Commented Sep 15, 2015 at 6:41

2 Answers 2

1

Filter your array by another scope var that is bound to your SELECT

<select ng-model="selectedNoteNumber">YOUR OPTIONS HERE</select>

<div ng-repeat="name in homes | filter: { 'NoteNumber': selectedNoteNumber }">
    {{name.city}}
</div>
Sign up to request clarification or add additional context in comments.

Comments

0

You can try this

<select ng-model="NoteNumber" ng-options="homes.NoteNumber as homes.NoteNumber for NoteNumber in homes"> </select>

<div ng-repeat="name in homes">
    <span ng-if="NoteNumber !== 'null'">{{name.city}}</span>
</div>

Hope this helps

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.