0

I have a dropdown list of countries. and when iam selecting a particular country my output should be filtered with details of only that country to be displayed following is my code but not working properly.

<label for="filtercountry" class="control-label col-xs-2">Filter By Country</label>

<div class="col-xs-2">

        <select class="form-control">
            <option value="None">-- Select --</option>
            <option ng-model="Tofilter.country" value="India" ng-change="changed()">India</option>
            <option ng-model="Tofilter.country" value="USA" ng-change="changed()">USA</option>
            <option ng-model="Tofilter.country" value="Pakistan" ng-change="changed()">Pakistan</option>
            <option ng-model="Tofilter.country" value="China" ng-change="changed()">China</option>
            <option ng-model="Tofilter.country" value="Australia" ng-change="changed()">Australia</option>
        </select>
    </div>`<ul id="result">

Name :{{x }}

`

3 Answers 3

1

Put ng-change on the select element:

<select class="form-control" ng-change="changed()">
Sign up to request clarification or add additional context in comments.

Comments

0

it's not necessary to put your model in all option, put it in select

<select class="form-control" ng-change="changed()" ng-model="Tofilter.country">

Comments

0
<div class="col-xs-2">

        <select class="form-control" ng-change="changed()" ng-model="Tofilter.country" >
            <option value="None">-- Select --</option>
            <option value="India" >India</option>
            <option value="USA" >USA</option>
            <option value="Pakistan" >Pakistan</option>
            <option value="China" >China</option>
            <option value="Australia" >Australia</option>
        </select>
    </div>

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.