这是我的html文件代码。在我的mongo数据库中frequencyType添加为frequencyType = "1" 但我想要frequencyType = NumberInt(1);
frequencyType
frequencyType = "1"
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)。
frequencyType = NumberInt(1)
我建议您尝试使用indexOf。
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>
演示版 **[Fiddle](http://jsfiddle.net/EyBVN/38/)**
**[Fiddle](http://jsfiddle.net/EyBVN/38/)**
因此发送给mongoDB的$scope.selectedItem价值
$scope.selectedItem