Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<select> placeholder with angular/bootstrap not working

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 :)

like image 895
unludo Avatar asked Jun 11 '14 09:06

unludo


People also ask

Can I give placeholder for select tag?

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.

How do you select a placeholder?

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.

How do I show placeholder in dropdown?

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.


1 Answers

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/

like image 115
Diana Nassar Avatar answered Sep 19 '22 18:09

Diana Nassar