简体   繁体   English

AngularJS:占位符<select>在 ng-repeat 里面

[英]AngularJS: Placeholder for <select> inside ng-repeat

I am trying to add the placeholder inside html select tag in ng-repeat for angularJS application.我正在尝试在 ng-repeat 的 html select 标签中为angularJS应用程序添加占位符。

Link to JS fiddle链接到 JS 小提琴

My HTML looks something like我的 HTML 看起来像

<div ng-repeat="item in items">
<div class="form-group">
   <label for="product">Product</label>
     <select class="form-control" ng-model="item.product"  ng-options="product as product.name for product in products"  plceholder="Select">        
     <option value="" disabled selected>placeholder</option>
     <!-- tried adding the above following line but it wont get added -->
  </select>
</div>
</div>

and the controller has this控制器有这个

function TodoCtrl($scope) {

    $scope.items=[{name: "item1"},{name: "item2"},{name: "item3"}];
    $scope.products = [{name: "product2", quantity: 2}, {name: "product1", quantity: 2}, {name: "product3", quantity: 2}];

}

I tried adding the option value but it wont get added.我尝试添加选项值,但它不会被添加。 Can any of you guide me on how to approach this solution你们中的任何人都可以指导我如何处理这个解决方案

尝试这个:

<option value="">Please select your option</option>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM