Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在前端处理来自后端的枚举_Java_Angularjs - Fatal编程技术网

Java 如何在前端处理来自后端的枚举

Java 如何在前端处理来自后端的枚举,java,angularjs,Java,Angularjs,我在前端使用AngularJS 1.4,在后端使用Java,在前端可以选择很多选项,例如国家: GERMANY FRANCE USA RUSSIA 枚举是用大写字母写的,我将在前端对此进行自定义(例如,法国将变成法国) 我现在的问题是,是否有指令或任何其他支持在前端执行此操作。查看此链接 它有一个自定义的过滤器编写,可以帮助您 下面是上面给出的链接中的代码 <!DOCTYPE html> <html ng-app="HelloApp"> <head>

我在前端使用AngularJS 1.4,在后端使用Java,在前端可以选择很多选项,例如国家:

GERMANY
FRANCE
USA
RUSSIA
枚举是用大写字母写的,我将在前端对此进行自定义(例如,法国将变成法国)

我现在的问题是,是否有指令或任何其他支持在前端执行此操作。

查看此链接

它有一个自定义的过滤器编写,可以帮助您

下面是上面给出的链接中的代码

<!DOCTYPE html>

<html ng-app="HelloApp">
<head>
    <title></title>
</head>
<body ng-controller="HelloCtrl">
  <form>
      <input type="text" ng-model="name"/>
    </form>
    <div>{\{name|titlecase}}</div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  <script type="text/javascript">
        // Code defining custom module consisting of a filter
        // The module needs to be included as dependency for using the filter, titlecase
        //
        angular.module('CustomFilterModule', [])
            .filter( 'titlecase', function() {
                return function( input ) {
                    return input.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
                }
            });
        // Angular App on this page 
        // Included CustomFilterModule as dependency
        //
        angular.module('HelloApp', [ 'CustomFilterModule'])
            .controller('HelloCtrl', ['$scope', function($scope){
                $scope.name = '';
            }])
    </script>
</body>
</html>

{{name | titlecase}
//定义由筛选器组成的自定义模块的代码
//该模块需要作为使用过滤器titlecase的依赖项包括在内
//
angular.module('CustomFilterModule',[])
.filter('titlecase',函数(){
返回函数(输入){
返回input.replace(/\w\S*/g,函数(txt){return txt.charAt(0.toUpperCase()+txt.substr(1.toLowerCase();});
}
});
//此页面上的Angular应用程序
//包含CustomFilterModule作为依赖项
//
angular.module('HelloApp',['CustomFilterModule']))
.controller('HelloCtrl',['$scope',函数($scope){
$scope.name='';
}])
查看此链接

它有一个自定义的过滤器编写,可以帮助您

下面是上面给出的链接中的代码

<!DOCTYPE html>

<html ng-app="HelloApp">
<head>
    <title></title>
</head>
<body ng-controller="HelloCtrl">
  <form>
      <input type="text" ng-model="name"/>
    </form>
    <div>{\{name|titlecase}}</div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
  <script type="text/javascript">
        // Code defining custom module consisting of a filter
        // The module needs to be included as dependency for using the filter, titlecase
        //
        angular.module('CustomFilterModule', [])
            .filter( 'titlecase', function() {
                return function( input ) {
                    return input.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
                }
            });
        // Angular App on this page 
        // Included CustomFilterModule as dependency
        //
        angular.module('HelloApp', [ 'CustomFilterModule'])
            .controller('HelloCtrl', ['$scope', function($scope){
                $scope.name = '';
            }])
    </script>
</body>
</html>

{{name | titlecase}
//定义由筛选器组成的自定义模块的代码
//该模块需要作为使用过滤器titlecase的依赖项包括在内
//
angular.module('CustomFilterModule',[])
.filter('titlecase',函数(){
返回函数(输入){
返回input.replace(/\w\S*/g,函数(txt){return txt.charAt(0.toUpperCase()+txt.substr(1.toLowerCase();});
}
});
//此页面上的Angular应用程序
//包含CustomFilterModule作为依赖项
//
angular.module('HelloApp',['CustomFilterModule']))
.controller('HelloCtrl',['$scope',函数($scope){
$scope.name='';
}])
视图中的

<select ng-model="selectedCountry" ng-options="country as country.name for country in countries | filter:filterUpperCamelCase"></select>
鉴于:

<select ng-model="selectedCountry" ng-options="country as country.name for country in countries | filter:filterUpperCamelCase"></select>

给它一个成员,'name',值为“German”,“France”…您可以编写自己的角度过滤器,或手动映射服务器响应中的值。您的后端使用什么框架?Spring(启动、Rest、数据…)给它一个成员,'name',值为“German”,“France”…您可以编写自己的角度过滤器,或者手动映射服务器响应中的值。后端使用什么框架?Spring(启动、Rest、数据等)链接可能会随着时间的推移而中断。最好把重要的部分复制到你的答案中。只有链接的答案也会被否决。链接会随着时间的推移而中断。最好把重要的部分复制到你的答案中。只有链接的答案也往往被否决。