本文介绍了NG-选择只给出了字符串,但我想整的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的角度HTML文件code。
在我蒙戈数据库frequencyType加入 frequencyType =1
但我想的 frequencyType = NumberInt(1)
This is my angular html file code . In my mongo database frequencyType added as frequencyType = "1" but I want frequencyType = NumberInt(1) ;
<div class="span4">
<select class="span12 combobox" ng-model="frequencyType" required>
<option value="1">Daily</option>
<option value="2">Weekly</option>
<option value="3">Monthly</option>
<option value="4">Yearly</option>
</select>
</div>
我在数据库中获取的 frequencyType =1,但我想的 frequencyType = NumberInt(1)
推荐答案
我建议你尝试使用的indexOf
。
JS
function MyCtrl($scope) {
$scope.values = ["Daily","Weekly","Monthly","Yearly"];
$scope.selectedItem = 0;
}
HTML
<div ng-app ng-controller="MyCtrl">
<select ng-model="selectedItem" ng-options="values.indexOf(selectedItem) as selectedItem for selectedItem in values"></select>
selectedItem: {{selectedItem}}
</div>
演示 骨节病>
所以,发送到MongoDB的 $ scope.selectedItem
值
So send to mongoDB $scope.selectedItem
value
这篇关于NG-选择只给出了字符串,但我想整的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!