我的HTML代码是
<select2 [value]="student" (valueChanged)="studentvaluechanged($event)" [data]="data.getStudentList()"id="student" name="student"
placeholder="Student Name*">
</select2>
答案 0 :(得分:0)
使用jQuery
$("#student").select2({
placeholder: "Student Name*",
allowClear: true
});
或者您可以尝试
<select2 [value]="student" (valueChanged)="studentvaluechanged($event)" [data]="data.getStudentList()"id="student" name="student">Student Name*</select2>
答案 1 :(得分:-1)
我找到了解决方案。添加[options]="{ placeholder: 'Student Name*' }"
后,它现在可以使用了。
<select2 [value]="student" (valueChanged)="studentvaluechanged($event)" [data]="data.getStudentList()"id="student" name="student"
[options]="{ placeholder: 'Student Name*' }">
</select2>