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>