1

私はAngularJSが初めてです。コマンドをサーバーに POST すると、サーバーから応答が返されます。私の POST コマンドは正常に動作します。これは、応答をアラート ビューに配置し、JSON として返すため、アラート ビュー内で応答を確認できるためです。

これが私のコードです:

var appControllers = angular.module('app', ['jsonService']);
appControllers.controller('post', function($scope, $http) {

            $http({
                withCredentials: true,
                method : 'POST',
                url : 'http://myURL/command',
                data : 'myData',
                headers : {
                'Content-Type' : 'application/x-www-form-urlencoded;charset=UTF-8'
                }
                }).success(function (data, status, headers, config) {
                        var JSONData = JSON.stringify(data);
                        $scope.persons = JSONData;
                           alert(JSONData);// assign  $scope.persons here as promise is resolved here
                }).error(function (data, status, headers, config) {
                        $scope.status = status;
                         alert(status);
                });
    });

私の質問: JSON 内の特定の 1 つの項目を解析したいと考えています。JSON の適切な子に到達するためにドット表記を使用する必要があることはわかっていますが、ドット表記を使用すると機能しません。

ここに私のHTMLコードがあります:

<ul data-ng-controller="post">
        <li ng-repeat="person in persons">
        <div><a href="http://button2" data-role="button" ng-bind="person.firstName"></a></div>
        </li>
    </ul>

ヒントやヘルプをいただければ幸いです。

4

1 に答える 1