I would like to have a select with a placeholder in angularjs with bootstrap. The solutions I have found do not work with angular
Here is my angular markup:
<select ng-model="myModel" ng-options="p.name for p in ..." class="form-control list-selector required"> <option value='' disabled selected>Please Choose</option> </select>
If someone has a working solution...
thanks :)
There is no placeholder attribute in 'select' tag but it can make the placeholder for a 'select' box. There are many ways to create the placeholder for a 'select' box.
Select box with a placeholder First, you need to create your select items with the help of the <option> tag. Then, set the disabled and selected attributes for your empty element, which is supposed to be the placeholder. Now, you can see that the first line is like a placeholder field.
Answer: Use the disabled and selected Attribute There is no attribute like input's placeholder for select box dropdown. However, you can create similar effect by using the HTML disabled and selected attribute on a <option> element that has empty value.
You need to add an empty option to your select:
<option value="">- Please Choose -</option>
Here is a working example: http://jsfiddle.net/DianaNassar/FShdc/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With