1

I have this dropdownlist in my template:

    <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
        <div class="input-group input-group-sm">
            <select class="form-control" 
                    data-ng-options="o.name for o in list.itemsStatus" 
                    data-ng-model="list.currentItemsStatus"
                    ng-change="list.getItems(o.id)">   
            </select>
        </div>
    </div>

Here is how is defined itemsStatus in controller:

  this.itemsStatus = [{ name: "all", id: 1 }, { name: "new", id: 2 }, { name: "toUpdate", id: 3 }];

when new item is selected I fire this function:

    function getItems(status) {
        switch (status) {
            case 1:
                break;
            case 2:
                break;
            case 3:
                break;
            default:
        }
    }

But passed parameter- status is always undefined.

How can I pass to getItems() event the selected item as parameter?

1 Answer 1

2

ng-change event can't pass ng-options current item as value.

You already do have selected value inside your ng-model, so you can pass your model which already has o(current selected value)

ng-change="list.getItems(list.currentItemsStatus.id)"    
Sign up to request clarification or add additional context in comments.

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.