How Do I Set A Prompt On A Select Using Ng-options? June 11, 2024 Post a Comment I have a select that uses ng-options to populate the select as follows: <selectclass="form-control"ng-model="Data.selectedPerson"ng-options="v as v.Name for v in Data.people track by v.Name"><!-- Add your default option here --><optionvalue="">Please select a person</option></select>CopyYou could also change the text based on the condition:- <option value="">{{ Data.people.length ? "Please select a person" : "No one available for selection" }}</option> CopyYou can also remove it from DOM if it has already a selected value. <option ng-if="!Data.selectedPerson" value="">Please select a person</option> Copy Share Post a Comment for "How Do I Set A Prompt On A Select Using Ng-options?"
Post a Comment for "How Do I Set A Prompt On A Select Using Ng-options?"