Laravel视图文件中的代码:
<select class="form-control" ng-model="voucher.card_type" >
<option value="">Choose Card Type</option>
<option ng-repeat="cardList in cardTypes" ng-value="@{{cardList.id}}">
@{{cardList.card_type}}
</option>
</select>
预期的html标签:
<select class="form-control ng-pristine ng-valid ng-empty ng-touched" ng-model="voucher.card_type">
<option value="">Choose Card Type</option>
<!-- ngRepeat: cardList in cardTypes --><option ng-repeat="cardList in cardTypes" ng-value="57" class="ng-binding ng-scope" value="57">ChristmasCard</option><!-- end ngRepeat: cardList in cardTypes -->
<option ng-repeat="cardList in cardTypes" ng-value="58" class="ng-binding ng-scope" value="58">AnniversaryCard</option>
<!-- end ngRepeat: cardList in cardTypes -->
但是它让我得到了名称而不是与ng-value相同的id的value参数。
HTML标记已创建:
<select class="form-control ng-pristine ng-valid ng-empty ng-touched" ng-model="voucher.card_type">
<option value="">Choose Card Type</option>
<!-- ngRepeat: cardList in cardTypes --><option ng-repeat="cardList in cardTypes" ng-value="57" class="ng-binding ng-scope" value="ChristmasCard">ChristmasCard</option><!-- end ngRepeat: cardList in cardTypes -->
<option ng-repeat="cardList in cardTypes" ng-value="58" class="ng-binding ng-scope" value="AnniversaryCard">AnniversaryCard</option>
<!-- end ngRepeat: cardList in cardTypes -->
我没有在选项中提供value参数,它一直工作到2018年10月结束,并在value中获取id,突然之间,值获取的是名称而不是id。
有帮助吗? 我的angular js版本是1.5.5