I have this select which i need the default value to be empty, tried adding a option with value="?" and selected="selected" but it wont work, any ideas?
<select class="form-control"
id="Select7"
name="grossweightmeasurementunitcode"
ng-model="itemForm.grossweightmeasurementunitcode"
ng-required="true">
<option ng-repeat="unidadepeso in unidadespeso" value="{{unidadepeso.commoncode}}">{{unidadepeso.sigla}}</option>
</select>
try this:
<select
class="form-control"
id="Select7"
name="grossweightmeasurementunitcode"
ng-model="itemForm.grossweightmeasurementunitcode"
ng-required="true">
<option value="">--Select--</opton>
<option ng-repeat="unidadepeso in unidadespeso" value="{{unidadepeso.commoncode}}">{{unidadepeso.sigla}}</option>
</select>
Related
I want to tell user to select any option from select other than first (index=0). I saw few examples and tried but not working for me:
<select ng-model="patient.gender" name="gender" class="form-control" required>
<option>- Select -</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
<div class="error" ng-show="Form.gender.$invalid">
Select gender
</div>
What to change here?
provide empty(default value) to option, so required field validation will fire on selection.
Html:
<select ng-model="patient.gender" name="gender" class="form-control" required>
<option value=''>- Select -</option> //Default value to empty
<option value="Male">Male</option>
<option value="Female">Female</option>
<option value="Other">Other</option>
</select>
Is it possible to pass the who object using ng-repeat in options?
Example:
<select id="cREmp123" ng-model="vm.selEmployee">
<option value="" selected>Choose...</option>
<option ng-repeat="emp in vm.employeeList" value="vm.employeeList[$index]">{{emp.strEmpFirstName}}</option>
</select>
I tried this also
<select id="cREmp123" ng-model="vm.selEmployee">
<option value="" selected>Choose...</option>
<option ng-repeat="emp in vm.employeeList" value="{{emp}}">{{emp.strEmpFirstName}}</option>
</select>
I hope somebody will answer me.
I tried using ng-options and it doesn't solve my problem
Have you tried ng-options?
Sample code for your reference
<select id="cREmp123" ng-model="selEmployee"
ng-options="employee as employee.strEmpFirstName for employee in employeeList">
<option value="" disabled selected>- Please Choose -</option>
</select>
https://jsfiddle.net/uovcs2dr/
I have a problem in selecting the default value of the select option when I try to load the page,this is my code:
<select ng-model="sortKey" class="ng-valid ng-pristine">
<option value="LastName" selected="selected">Nom</option>
<option value="FirstName">Prenom</option>
<option value="Class">Classe</option>
</select>
I have used the selected="selected" attribute but always I have this problem
Thanks for help
this is a demo:
<select ng-model="sortKey" style="border-radius: 20px;width: 135px;height: 32px;margin-left: 0px;margin-right: 22px;" class="ng-valid ng-dirty ng-pristine">
<option selected value="LastName" >Nom</option>
<option value="FirstName">Prenom</option>
<option value="Class">Classe</option>
</select>
Consider the following HTML sample:
<select class="form-control form-input-toggle ng-pristine ng-invalid ng-invalid-required ng-touched" ng-model="form.fields['ReportingParty.Contact.Title.Text'].value" ng-change="run()" required="" ng-disabled="!editable(form)">
<option value="">Select...</option>
<optgroup label="----------">
<option value="MR">Mr</option>
<option value="MRS">Mrs</option>
</optgroup>
<optgroup label="----------">
<option value="2LT">Second Lieutenant</option>
<option value="AB">Able Seaman</option>
<option value="ABBOT">Abbot</option>
</optgroup>
</select>
How can I select the value as MR, or Second Lieutenant using WebdriverIO?
I have tried using .selectByValue([ng-model="form.fields[\'ReportingParty.Contact.Title.Text\'].value "], "MR" ), but it didn't work.
Use http://webdriver.io/api/action/selectByValue.html
browser.selectByValue("#selectbox", "2LT")
Try this
client.click('//*[#id="selectComboId"]/option[#value="2LT"]');
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 }}
`
Put ng-change on the select element:
<select class="form-control" ng-change="changed()">
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">
<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>