Javascript 如何使用Angularjs从json中删除字符串中的数字?

Javascript 如何使用Angularjs从json中删除字符串中的数字?,javascript,angularjs,json,api,ng-options,Javascript,Angularjs,Json,Api,Ng Options,我正在研究角度。代码中的Api使用字符串传递json值,字符串中包含数字和字母。但我的要求是只显示字母表,并从dropdownlist中的字符串中删除数字 我的剧本: staffService.getBaseBranches() .success(function(data) { $scope.baseBranches = data; }) .error(function(error, status) { showError(error, sta

我正在研究角度。代码中的Api使用字符串传递json值,字符串中包含数字和字母。但我的要求是只显示字母表,并从dropdownlist中的字符串中删除数字

我的剧本:

staffService.getBaseBranches()
    .success(function(data) {
      $scope.baseBranches = data;

    })
    .error(function(error, status) {
      showError(error, status);
      notificationFactory.error("Unable to load base branches.");
    });
我的html:

 <div class="form-group">
        <label>Branch : <i class="mandate">*</i></label>
           <select class="form-control input-md" name='branchName' ng-model="query.branchName" ng-options="branch.branchName as branch.branchName for branch in baseBranches">

           <option value="" selected>-- Select Branch --</option>
            </select>
                  <span class="error" ng-show="search_form.branchName.$error.required">Branch is required</span>
</div>
我该怎么做?请帮我解决这个问题。

您可以通过调用showName函数在显示branchName时更改branchName。showName将负责从字符串中删除数字

代码


提供示例json以供参考。@Sumit这里是json[{branchName:2343 hyderabad,branchCode:2343},{branchName:6768 Bangalore,branchCode:6768},{branchName:5657 chennai,branchCode:5657}]@Pankaj Parkar你能告诉我如何在我的AngularI表达式中使用这个吗?我不明白,问题是什么?@Pankaj Parkar你的答案很好,但我如何在我的{}表达式中使用它。@Pankaj只要我选择下拉菜单,值就会出现在角度表达式中。我应该在我的ng模型中做什么更改?您不能在ng options指令中使用{{}}
ng-options="branch.branchName as showName(branch.branchName) for branch in baseBranches"
$scope.showName = function(branchName ){
   return branchName.replace(/\d+/g, '')
}