小编Hes*_*sry的帖子

在 AngularJS 中使用 <select> 和 <option>

我有这个锚标记,我根据对象的日期更改我的视图。我正在尝试将其更改为选择选项,但它没有按照我的方式工作。

这是锚标记语法:

 <a href="#" ng-repeat="item in home.prData" ng-click="home.selectedPr = item; $event.preventDefault();
 $event.stopPropagation();">{{item.date}}</a>
Run Code Online (Sandbox Code Playgroud)

我试图将其更改为使用选择选项时的样子

 <select st-search="{{item.date}}" class="show-tick form-control dropdown_custom_list">
      <option value="">- select a date -</option>
      <option ng-repeat="item in home.prData" value="{{home.selectedPr = item}}">{{item.date}}
      </option>
  </select>
Run Code Online (Sandbox Code Playgroud)

我创建了一个示例 plunkr 来实现我想要实现的目标:

我的代码

javascript angularjs ng-options dropdown angularjs-select

5
推荐指数
2
解决办法
2万
查看次数