GET 请求,但未在视图中获取结果

GET request but not getting results in the view

本文关键字:视图 获取 结果 请求 GET      更新时间:2023-09-26

我正在开发一个 Web 应用程序,我有机会从数据库中在我的视图上呈现一个表。之后,我执行了一个 ID 请求,以便我可以单击表上的结果并呈现视图以查看该行的详细内容。

问题是:一切正常,没有显示错误消息,并且使用chrome的开发工具,我可以看到检索了带有数据的json,但是应该打印重用的行没有显示。我的控制器如下:

app.controller("ListaID",function($scope, $http, $routeParams) {
    $http.get('http://localhost:8000/organite/listagem/'+$routeParams.id).success(function(data){
        console.log($routeParams.id);
        $scope.obito = data;
    }).error(function(){
        alert("Ocorreu um erro inesperado!");
    });
});

该应用程序.js是:

var app = angular.module("organite", ['ngRoute']);
app.config(function ($routeProvider) {
    $routeProvider
        .when('/organite', {
            templateUrl: 'home.html'
        })
        .when('/organite/tables', {
            controller: 'Lista',
            templateUrl: 'tables.html'
        })
        .when('/organite/tables/:id', {
            controller: 'ListaID',
            templateUrl: 'tableID.html'
        })
        .otherwise({
            redirectTo: '/organite'
        });
});

视图是:

<div class="tables">
    <h3 class="title1">Vista detalhada</h3>
    <div class="bs-example widget-shadow" data-example-id="hoverable-table">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>Número Sequencial</th>
                    <th>Anotações</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>{{obito.NUM_SEQUENCIAL}}</td>
                    <td></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>

我的 JSON 是:

[{"URG_OBITO":1111,"NUM_SEQUENCIAL":1111,"NUM_PROCESSO":1111,"DTA_OBITO":"1111","HORA_OBITO":1111,"FALECEU_HOSP":"S","COD_ESPECIALIDADE":1111,"HSA":"1","NUM_EPISODIO":1111,"COD_MODULO":"1111","FSMS":1,"FEMAIL":1,"DSMS":"1111","DEMAIL":"1111","DTA_REGISTO":"1111","DES_ESPECIALIDADE":"1111"}]

(我故意将值更改为"1111")

请在收到回复时尝试data.data

$scope.obito = data.data;

我的更新视图:

<div class="tables">
    <h3 class="title1">Vista detalhada</h3>
    <div class="bs-example widget-shadow" data-example-id="hoverable-table">
        <table class="table table-hover">
            <thead>
                <tr>
                    <th>Número Sequencial</th>
                    <th>Anotações</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td ng-repeat="x in obito">{{x.NUM_SEQUENCIAL}}</td>
                    <td></td>
                </tr>
            </tbody>
        </table>
    </div>
</div>