1

Good morning, I have a problem with a placeholder not functioning. Having researched SO for similar problems, got this one that describes a pretty similar issue, but no solutions for my problems:

AngularJS: ng-placeholder not working

I have a select field:

  <select ng-model="form.experience"
          name="experience"
          ng-options="e for e in experience"
          class="form-control"
          data-placeholder="Experience"
          tabindex="11"
          required=""/>

In controller I have:

$scope.experience = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

Then, in browser I see the following. My understanding is that it should already be working, however the placeholder is not displayed in the select field. Would appreciate some help as I am obviously missing something.

enter image description here

1 Answer 1

2

placeholder wont work in select while using ng-options

two solution :

<select ng-model="form.experience"
      name="experience">
    <option >Experience</option>
    <option ng-repeat="e in experience"></option>
 </select>

second is :

$scope.experience = ['Experience',1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
$scope.form.experience = 'Experience';

  <select ng-model="form.experience"
      name="experience"
      ng-options="e for e in experience"
      class="form-control"
      data-placeholder="Experience"
      tabindex="11"
      required=""/>
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. So that is the problem, I attempted using placeholder in select while using ng-options, good to know. Marking as approved

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.