如何将JSON格式转换为AngularJS的视图部分的字符串

时间:2015-02-13 11:46:54

标签: java json angularjs web-services

Iam使用Web服务以JSON格式从数据库中获取数据。现在我需要在我的AngularJS的视图部分中将json格式呈现为普通字符串。

这是我的HTML文件index.html

<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
    <script src="./hello.js"></script>
</head>
<body ng-controller="Hello">
    <div ng-repeat="greeting in greetings">
        <p>The ID is {{greeting.userId}}</p>
        <p>The content is {{greeting.userName}}</p>
    </div>
</body>

`

这是我的java脚本文件hello.js

function Hello($scope, $http) {
$http.get('http://localhost:8080/RESTJerseyExample/rest/restfultest/GetCarValues').
    success(function(data) {
        $scope.greetings = data;
    });
}`

1 个答案:

答案 0 :(得分:0)