Reputation: 7018
Code:
var app = angular.module('myApp', ['smart-table']);
app.controller("MyController", function ($scope, $http) {
$scope.get = function ()
{
$http.get('JsonProcessor.do').
success(function (data, status, headers, config)
{
$scope.rowCollection = data[0];
console.log("Result from Database: ", data[0]); //prints value
console.log(data[0].ID); //prints ID
}).
error(function (data, status, headers, config)
{
});
};
});
I am able to fetch data and display it in console but I wonder its not displayed inside table.
However, ng-repeat
creates four rows in table but with no data
Html:
<table st-table="rowCollection" class="table table-striped">
<thead>
<tr>
<th>Unique Id</th>
<th>Date Created</th>
<th>Doc Url</th>
<th>Time Stamp</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in rowCollection">
<td>{{row.ID}}</td>
<td>{{row.DATE_CREATED}}</td>
<td>{{row.URL}}</td>
<td>{{row.TIMESTAMP}}</td>
</tr>
</tbody>
</table>
What could be the issue?
Upvotes: 0
Views: 841
Reputation: 1786
Since your data is coming from a service call you must use st-safe-src for smart table.
http://lorenzofox3.github.io/smart-table-website/
stSafeSrc attribute
"If you are bringing in data asynchronously (from a remote database, restful endpoint, ajax call, etc) you must use the stSafeSrc attribute. You must use a seperate collection for both the base and safe collections or you may end up with an infinite loop."
Upvotes: 2