How do I get the id of the button clicked on a row of result listings by Angular JS?

0

How to get the button id clicked on a row of result listings by Angular JS?

In the HTML page I can use list.id, but in the code in AngularJS, the following code returns me undefined :

id;

$scope.id;

$scope.listagensRelatorios.id;

$scope.parametro.id;

$routeParams.id 


    app.controller("listagemRelatoriosController", function($scope, $http, $location, $q) {

    $scope.listagensRelatorios = [];
    $scope.listagemRelatorio = {};

    carregarListagemRelatorios = function() {

        $http({
            method : 'GET',
            url : 'http://localhost:8080/listagemRelatorios',

        }).then(function(response) {
            $scope.listagensRelatorios = response.data;

        }, function(response) {
            console.log(response.data);
            console.log(response.status);
        });

    };


    gerarRelatorioSelecionado = function() {

        $http({
            method : 'GET',
            url : 'http://localhost:8080/listagemRelatorios' + $scope.listagensRelatorios.id,

        }).then(function(response) {
            $scope.listagensRelatorios = response.data;

        }, function(response) {
            console.log(response.data);
            console.log(response.status);
        });

    };



    carregarListagemRelatorios();
    gerarRelatorioSelecionado();

});
    
asked by anonymous 30.10.2017 / 14:09

1 answer

0

You can pass the id on the function call in html.

HTML:

 <div ng-click="getId(list.id)">List item</div>

Function:

 $scope.getId = function(param) {
   console.log(param);
   //insira o código aqui
 }

I hope I have helped.

    
04.03.2018 / 21:50