imadfooki fooki
imadfooki fooki

Reputation: 187

Passing the ID to the function in angular JS

I am trying to get the ID and pass the function through angular JS but I am not getting the ID in the fuction.

Here is the Code

<tr ng-repeat="record in records | filter:filters.search| filter: filters.searchdd | filter:customFilter(unit)">
                <td>{{ record.name }}</td>
                <td>{{appctrl.currentOrgType.name}}</td>
                <td> {{record.id}}</td>
                <td>
                    <div class="dropdown">
                        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                            select option
                        <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                        <li><a href="#"  ng-click="locateOnMap(record.id)">Locate on Map</a></li>
                        <li><a href="#">Edit Coordinates</a></li>

Here I am calling the ID in alert. But I am getting nothing

$scope.locateOnMap=function(id)
    {
       alert('Get ID ' + id); 

    }

Upvotes: 1

Views: 1565

Answers (1)

Lee.Winter
Lee.Winter

Reputation: 710

I would test with console.log

$scope.locateOnMap=function(record)
    {
       console.log('record',record);
    }

and pass the whole record in to make sure id exists

<tr ng-repeat="record in records | filter:filters.search| filter: filters.searchdd | filter:customFilter(unit)">
                <td>{{ record.name }}</td>
                <td>{{appctrl.currentOrgType.name}}</td>
                <td> {{record.id}}</td>
                <td>
                    <div class="dropdown">
                        <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
                            select option
                        <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
                        <li><a href="#"  ng-click="locateOnMap(record)">Locate on Map</a></li>
                        <li><a href="#">Edit Coordinates</a></li>

Upvotes: 1

Related Questions