-2

<option>是否可以在 in 中添加 font-awesome 图标<select>

  <body ng-app>
    <i class="fa fa-camera-retro"></i> fa-camera-retro<br>
    <select ng-model="choice" class="fa">
      <option value="">Choose</option>
      <option value="icon camera">icon camera</option>
      <option value="icon bell">icon bell</option>
      <option value="icon bicycle">icon bicycle</option>
    </select>
4

1 回答 1

1

由于 font-awesome 图标是字体,它们可以通过 Unicode 添加到选项中:

<script src="//unpkg.com/angular/angular.js"></script>
<link rel="stylesheet" href="//unpkg.com/font-awesome/css/font-awesome.css">
  <body ng-app>
    <i class="fa fa-camera-retro"></i> fa-camera-retro<br>
    <select ng-model="choice" class="fa">
      <option value="">Choose</option>
      <option value="&#xf030; camera">&#xf030; camera</option>
      <option value="&#xf0f3; bell">&#xf0f3; bell</option>
      <option value="&#xf206; bicycle">&#xf206; bicycle</option>
    </select>
    <br>
    Choice = <span class="fa">{{choice}}</span>
    <br><span class="fa">&#xf030;-&#xf0f3;-&#xf206;</span>
  </body>

PLNKR 上的DEMO

字体真棒备忘

于 2019-05-03T21:18:52.533 回答