Smart-Table "st-sort" not working

All we need is an easy explanation of the problem, so here it is.

I’m using angular v1.3.15. I’m fetching data by hitting an api and passing it through the scope to the smart table like so

enter image description here

Here is the data format of the ‘scope.rowCollection’ as seen on the console

enter image description here

Data populates fine but When i’m trying to click on the table-header and sort it using st-sort method, the table values go blank clearly not sorting the column. Here is a view of my html snippet

enter image description here

Can you please tell me what exactly am i doing wrong. The moment i use my own data collection set(NOT hard coded) the whole table values go haywire.
I have a feeling its something to do with the variable names that i’m using on the angular end.
Any help is much appreciated….Thanks

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

Following your comment Nikhil. Use st-safe-src like so:


<table st-table="displayedCollection" st-safe-src="rowCollection">
          <th st-sort="firstName">First Name</th>
          <th st-sort="lastName">Last Name</th>
        <tr ng-repeat="row in displayedCollection">


app.controller('Ctrl', function($scope, service) {
    $scope.displayedCollection = [];

    service.all.then(function(list) {
        $scope.rowCollection = list;
        $scope.displayedCollection = list;

That’s it.

Method 2

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.

Since I am getting data from restful service
st-table=”displayedCollection” st-safe-src=”rowCollection”
solve my issue

Method 3

I think it is trying to sort on in the way that you code it. Try the following to see if it works:


Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply