Is there a way to pass a JSON entry into the onClick event for triggering an alert box in AngularJS?
I'm attempting to display a message box with the content of a specific JSON entry when clicking on a row within a table. The issue seems to be isolated to this particular section as the rest of the table functions correctly.
<tr ng-repeat="x in json.tags | filter:filterName | filter:filterID | orderBy:myOrderBy:reverse" onClick="alert(x.AlertInfo)">
Below is the complete source code.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
</script>
<div ng-app="myApp" ng-controller="getJson">
<!-- <p>Status : {{statuscode}}</p>
<p>StatusText : {{statustext}}</p>-->
<input type="text" id="input" ng-model="filterName" placeholder="Search.." title="Type in a name">
<table id="myTable">
<tr>
<th ng-click="orderByMe('t1')" width="8%">t1</th>
<th ng-click="orderByMe('t2')" width="5%">t2</th>
<th ng-click="orderByMe('t3')" width="3%">t3</th>
</tr>
<tr ng-repeat="x in json.tags | filter:filterName | filter:filterID | orderBy:myOrderBy:reverse" onClick="alert(x.AlertInfo)">
<td>{{x.t1}}</td>
<td>{{x.t2}}</td>
<td>{{x.t3}}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('getJson', function($scope, $http, $interval) {
$scope.getData = function() {
$http.get('http://JSONGET').
then(function(response) {
$scope.statuscode = response.status;
$scope.statustext = response.statusText;
$scope.json = response.data;
console.log('Fetched data!');
});
};
$scope.orderByMe = function(x) {
$scope.myOrderBy = x;
};
$scope.intervalFunction = function(){
$scope.getData();
$interval(function(){
$scope.getData();
}, 15000);
};
$scope.intervalFunction()
});
</script>