angularjs – ng-select只给出字符串,但是我想要整数

前端之家收集整理的这篇文章主要介绍了angularjs – ng-select只给出字符串,但是我想要整数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的角html文件代码
在我的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值

原文链接:https://www.f2er.com/angularjs/144974.html

猜你在找的Angularjs相关文章