angular的json

前端之家收集整理的这篇文章主要介绍了angular的json前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在angular从servlet中获取的list数据是字符串格式,需要转为json格式,于是使用语法:

$scope.findOne=function(id){                
        typeTemplateService.findOne(id).success(
            function(response){
                $scope.entity= response;
                $scope.entity.brandIds=  JSON.parse($scope.entity.brandIds);//转换品牌列表
                $scope.entity.specIds=  JSON.parse($scope.entity.specIds);//转换规格列表
                $scope.entity.customAttributeItems= JSON.parse($scope.entity.customAttributeItems);//转换扩展属性

            }
        );                
    }

猜你在找的Angularjs相关文章