0

Here the div tag

<div wbr-pivot wbr-toolbar="true"  wbr-report="{ 'dataSource': { 'data':JSON.parse(WebDataRocks()),'dataSourceType': 'json'}}" >
</div>

here is the controller function

App.controller('Ctrl', ['$scope','serv', function ($scope,serv) {
    $scope.WebDataRocks = function () {
        return serv.WebDataRocks($scope.Filter).then(function (d) {
            return d.data;
        }, function (err) { });
    }
}]);

Please help!

  • 1
    You can't pass a promise to the view. It would look like `data: JSON.parse()`. Don't call that function in view. Instead call it in controller and assign the result to a scope variable to pass to view – charlietfl Mar 25 '21 at 22:21
  • Thank you for your answer, I made it like this `$scope.WebDataRocks = function () { servTotalIncomeReport.WebDataRocks($scope.Filter).then(function (d) {$scope.MyData = d.data;}, function (err) { });}` and the div is like this `
    ` , i recognize that too many calls are made from this function and the pivot table doesn't work
    – Wessam Al-Bakary Mar 25 '21 at 22:43
  • 1
    Did you call `$scope.WebDataRocks()` in controller? Did you define a default `myData` so it isn't undefined while waiting for promise to resolve? – charlietfl Mar 25 '21 at 22:50
  • Yes, I did. Also the api call appears in the network tab "chrome" more than 20 times, it just called once. The Pivot table didn't appear – Wessam Al-Bakary Mar 25 '21 at 22:56
  • 1
    Sure you aren't calling it in the view? that is a bad thing to do. Angular will render that view numerous times until scope stabilizes – charlietfl Mar 25 '21 at 22:57
  • Yes I am sure, the view is like this `
    `
    – Wessam Al-Bakary Mar 25 '21 at 22:59
  • The call is like this `$scope.WebDataRocks();` at the bottom of the controller – Wessam Al-Bakary Mar 25 '21 at 23:11

0 Answers0