Javascript 角度选择标记是在选项中显示不同文本的最简单方法,而不是';s绑定到ng模型

Javascript 角度选择标记是在选项中显示不同文本的最简单方法,而不是';s绑定到ng模型,javascript,html,angularjs,select,Javascript,Html,Angularjs,Select,我有这样一个选择: <label class="item item-input item-select"> <span class = "input-label"> Security: </span> <select name="scopeEnumId" ng-model="task.scopeEnumId"> <option>General</option> <o

我有这样一个选择:

<label class="item item-input item-select"> 
    <span class = "input-label"> Security:  </span> 
    <select name="scopeEnumId" ng-model="task.scopeEnumId">
        <option>General</option>
        <option>Very Restricted</option>
        <option>Staff-Only Access</option>
    </select>
</label>
我可以拥有用户看到的:一般、非常受限、仅限员工访问吗 但是对象看起来是这样的:

{
   scopeEnumId:'enum_restricted'
}

差不多

<option>enum_restricted as Very Restricted</option>
enum_受限为非常受限
我知道我可以用javascript实现,但我想知道是否有内置的东西。我什么也没找到,但这并不意味着什么:)


示例:

您可以使用选项标记上的“值”属性来设置所需的scopeEnumId值

例如:

<option value="veryRestricted">Very Restricted  </option>

假设您只是尝试将camelCase转换为常规camelCase,则过滤器将起作用:

app.filter('regularCase', function () {
  return function (id) {
    //convert camelCase to Regular Case
    return id.replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); });
  };
});
这样,您可以:

<option>{{scopeEnumId | regularCase}}</option>
{{scopeEnumId | regularCase}

能否与js代码共享,这样我们就可以看到您的尝试,并且很容易在angular中实现。不,我实际上是想让ng模型具有不同的值,我将更新问题以澄清这一点
{scopeEnumId : 'veryRestricted'}
app.filter('regularCase', function () {
  return function (id) {
    //convert camelCase to Regular Case
    return id.replace(/([A-Z])/g, ' $1').replace(/^./, function(str){ return str.toUpperCase(); });
  };
});
<option>{{scopeEnumId | regularCase}}</option>