Sign up ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I have the following JSONs

$scope.Facilities=
[
    {
        Name: "-Select-",
        Value: 0, 
        RegionNumber: 0
    },

    {
        Name: "Facility1",
        Value: 1, 
        RegionNumber: 1

    },

    {
        Name: "Facility2",
        Value: 2, 
        RegionNumber: 1
    },

    {
        Name: "Facility3",
        Value: 3, 
        RegionNumber: 2
    }
];

$scope.Regions=
[
    {
        Name: "-Select-",
        RegionNumber: 0
    },

    {
        Name: "USA",
        RegionNumber: 1
    },

    {
        Name: "Mexico",
        RegionNumber: 2
    }
];

I would have two DropdownLists in my app which will have one of these Jsons assigned to it.

Whenever you select a Region, a ng-change would be triggered. What I want is to make the Facility DDL to update it's values. It would only show the Facilities which have a RegionNumber equivalent to the selected Region's RegionNumber.

How could I achieve this? I'm using Angular JS, MVC...

Note: The -Select- Value must always appear, even if it's value is zero and is not equivalent to the selected Region.

share|improve this question

put on hold as off-topic by Jamal Nov 9 at 23:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions containing broken code or asking for advice about code not yet written are off-topic, as the code is not ready for review. After the question has been edited to contain working code, we will consider reopening it." – Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.