这是我的角html文件代码。
在我的mongo数据库中,frequencyType被添加为frequencyType =“1”
但我想要frequencyType = NumberInt(1);
在我的mongo数据库中,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)。
我建议你尝试使用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
所以发送到mongoDB $ scope.selectedItem值