Directives Angular - ng-repeat

0

I have a project with C # Web and define that I would use AngularJS to retrieve data from the Bank.

The query is done in the database normally the object is retrieved in the javascript of the class GetallDados that I defined. However in the interface when I use ng-repeat to present the data it shows the blank lines and in different amount of what I have in the bank. below is the section of methods I've created.

In HTML, only the buttons appear. debugging in the browser I realize that the data is located. If you can help me or indicate a material. I confess that my angle with angle is very basic.

- > C #

// AreaComum
    public JsonResult GetallDados ()
    {
        var areacomum = db.AreasComuns.ToList();
        return Json(areacomum, JsonRequestBehavior.AllowGet);
        //return Json(db.AreasComuns.ToList());

    }

- > JAVASCRIPT

var CondominioAreaComumApp = angular.module('CondominioAreaComumApp', []);
CondominioAreaComumApp.controller('AreaComumController', ['$scope', '$http', function ($scope, $http) {
    //debugger;

    $scope.nomeListaAreas = 'Lista de Areas Comuns';

    $scope.areacomum = [];
    $scope.GetAllAreaComum = function () {
        $http({
            method: "get",
            url: "/AreaComum/GetAllAreaComum"
        }).then(function (data) {
            debugger;
            $scope.areacomum = data;
        }, function (result) {
            //console.log(result);
            alert("Ocorreu um Erro ");
        })
    };

- > HTML                        {{nameAreaAreas}}

        <table cellpadding="12" class="table table-bordered table-hover">
            <tr>
                <td>
                    <b>ID</b>
                </td>
                <td>
                    <b>Descrição</b>
                </td>
                <td>
                    <b>Actions</b>
                </td>
            </tr>
            <tr ng-repeat="item in areacomum">
                <td>
                    {{item.ID}}
                </td>
                <td>
                    {{item.AreaComumDescricao}}
                </td>
                <td>
                    <input type="button" class="btn btn-warning" value="Atualizar" ng-click="UpdateUsu(item)" />
                    <input type="button" class="btn btn-danger" value="Excluir" ng-click="DeleteUsu(item)" />
                </td>
            </tr>
        </table>
    </div>
</div>
    
asked by anonymous 04.04.2018 / 04:53

1 answer

0

I think your problem is here:

$scope.areacomum = data;

The fact is that in order to retrieve the request response data it is necessary to access the data property of the parameter that is then injected into the link service of the angle. The right would then be something like:

$scope.areacomum = data.data;

Follow the angular documentation link below:

link $ http # $ http-returns

    
07.04.2018 / 23:06