Friday 15 January 2010

javascript - Angular State Dropdown Bound to Country Select -


I am trying to get a relevant state dropdown menu which is bound to the country so that only the related state can be displayed.

But for the solution to my implementation I have seen these two answers.

I can not get them to work and I'm missing something.

My favorite solution will use some existing NG filters, but I believe that only works on the array and not the objects

   

I tried to convert the object to orange, but it did not seem to work.

I can create a custom filter, but I hope to avoid this hope.

  & lt; Select ng-model = "user.state" ng-options = "state.name by state.id | customStateFilter: user.country.id" & gt;  

It seems that there should be no way to work ng-options without modifying the data.

Is there an existing angular filter that works on objects or how to make conditional arguments to dynamically filter objects?

You have some problems here (in addition to the state.countryid and < With a mismatch of code> country.id :

First comes after the track by (or, other words The filter comes right after the array, because it filters the array.)

Second , you are correct - in filter filter only Works on orange, not objects. Custom filters are required.

and end , filter does not accept an expression to evaluate the filter ( Filters: State.countryid = user.country.id , do not tell that this "expression" that you tried to provide does not compare it to === , but < Code> = ). To match a property to specify object , filter to match a property, either a The string accepts -

In your case, there is an object you need.

To keep this thing together:

  & lt; Ng-Model = "selectedState" ng-options = "Name of state for state states. Filter: {countryid: user.country.id}: state track by true.id" & gt; & Lt; Option value = "" & gt; Select state & lt; / Option & gt; & Lt; / Select & gt;  

No comments:

Post a Comment