0

I am using angular js smart table in my application. Every thing works fine during initial load. However I have a button (it is outside smart table) to refresh the data when some of the criteria changes. On button click I am calling changeView function which repopulates rowCollection data as shown below. As per my knowledge in angular js, this data change should be reflected in view (two-way data binding).

But after button click, only headers are appearing in my smart table, all the remaining data is getting removed. Can any one point me what is the flaw in my approach? getKPIModesData is retuning the required json data in correct format, there is no problem with that.

$scope.changeView = function(selectedAccount, selectedCarrierList, fromDate, toDate) {
                        $scope.rowCollection = DashboardsDataService.getKPIModesData(selectedAccount, selectedCarrierList, fromDate, toDate);                                               

                    }
4
  • are you returning a promise from getKPIModesData function? Commented Sep 19, 2014 at 11:26
  • No. I have not used any promises. is it mandatory to use to get the data from services? Commented Sep 19, 2014 at 11:33
  • 1
    it is a good practice, and btw use console.log($scope.rowCollection ) after this line $scope.rowCollection = DashboardsDataService.getKPIModesData(selectedAccount, selectedCarrierList, fromDate, toDate); and tell me if you still see the data you want to see Commented Sep 19, 2014 at 11:35
  • 1
    Now I realized the importance of the promises. console.log($scope.rowCollection )is not returning data which I want. In the service the ajax function call is returning correct json data but some other part of the code is effecting to return this data to my controlelr which I had over looked. Thanks for your help. Commented Sep 19, 2014 at 11:48

1 Answer 1

4

make sure

  1. you use the st-safe-src attribute so that smart-table watches your collection and is able to update its reference copy whenever you load/update your data.
  2. the displayed collection is different from the safe source collection otherwise you will enter an infinite loop.

You'll find more details (and a plunkr) on this github issue

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.