0

I have a <select> element in my HTML that is bound via ng-model to an object in the scope.

Initially I want the dropdown to read "Group..." but when the user clicks on the control I want "Group..." to be renamed to "All" so that "Group..." can never be selected, in the same sense that sites use text boxes with default text that gives you a hint to what the form is for and disappears when it gets user focus (e.g. A "Search..." field).

Here is my JSFiddle example which isn't working as I expected: http://jsfiddle.net/TXPJZ/561/

I figured that ng-onclick="myOptions[0].label = 'All'" would work, it should change the value of the data structure that populates the dropdown and thus change the dropdown options but it doesn't.

How do I make this work like I want?

1 Answer 1

2

ng-click is the directive you want, not ng-onclick. Using that it seems to work the way you want it to:

http://jsfiddle.net/TXPJZ/562/

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.