Currently I am stuck with drop down, the problem is the required validator and the default value selected
Snippet1.html
<div class="input-group" >
<select required name="industryType" id="industryType" [(ngModel)]="institution.industryType" aria-describedby="sizing-addon1" class="select-custom">
<option selected [value]="null">Select Industry</option>
<option value="IT">IT</option>
<option value="Business">Business</option>
<option value="Engineering">Engineering</option>
<option value="Teaching">Teaching</option>
<option value="Marketing">Marketing</option>
</select>
</div>
<button type="submit" class="btn btn-primary login-button border-custom">Add Industry</button>
On clicking button it asks me to fill the drop down but the problem is default value is not selected i.e Select Industry rather then showing the default value it shows nothing, but the validation works fine.
Snippet2.html
<div class="input-group" >
<select required name="industryType" id="industryType" [(ngModel)]="institution.industryType" aria-describedby="sizing-addon1" class="select-custom">
<option selected [value]="default">Select Industry</option>
<option value="IT">IT</option>
<option value="Business">Business</option>
<option value="Engineering">Engineering</option>
<option value="Teaching">Teaching</option>
<option value="Marketing">Marketing</option>
</select>
</div>
<button type="submit" class="btn btn-primary login-button border-custom">Add Industry</button>
On clicking button it does not asks me to fill the drop down but the default value is selected i.e Select Industry, validation doesn't work with this snippet can any one suggest me what I am doing wrong or what is the right way to do it?
requiredto your select if user must provide a value for that field<select ... required>...</select>. Concerning the default value, did you try something like :<option value="" selected>Select Industry</option>