Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

TypeError: Cannot read property 'serverSide' of undefined #452

Closed
edwardlau opened this issue Sep 23, 2015 · 3 comments
Closed

TypeError: Cannot read property 'serverSide' of undefined #452

edwardlau opened this issue Sep 23, 2015 · 3 comments

Comments

@edwardlau
Copy link

 angular.module('inspinia').controller('MainCtrl',['userService','serverService', '$scope', function(userService, serverService,$scope,$resource, DTOptionsBuilder, DTColumnDefBuilder){

    $scope.yesterday =function(){
        var defaultDate = new Date();
        defaultDate.setDate(defaultDate.getDate()-2);
        $scope.startDate = defaultDate;
        $scope.endDate = defaultDate;
        $scope.compareStartDate = defaultDate;
        $scope.compareEndDate =  defaultDate;
        $scope.thisTime = defaultDate;
    };

    $scope.yesterday();

    var userInfo = this;
    $scope.userId = -1;
    $scope.serverName = {};

    userService.getUserInfo().then(function(data){
          userInfo.user = data;

          userInfo.userId = data.userId;

          userService.getServer(userInfo.userId).then(function(data){

              userInfo.server = data;

              $scope.serverName.selected=data[0];

              serverService.vistiDay($scope.startDate,$scope.endDate,data[0]).then(function(data){
                  userInfo.domain = data;
                  console.log('searchServerName.domain',data)
                  $scope.serverTotal = data.total;
                  if(data.serverList.size!=0){
                      $scope.serverListData = data.serverList.content;
                  }
              })
          });
     });

}]);


<table datatable="ng" class="table table-striped table-bordered table-hover dataTables-example">
                    <thead>
                    <tr>
                        <th>日期</th>
                        <th>pv</th>
                        <th>uv</th>
                        <th>ip</th>
                        <th>跳出率</th>
                        <th>平均访问时长</th>
                        <th>平均访问页数</th>
                        <th>新访客</th>
                        <th>新访客比例</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="server in ::serverListData">
                        <td>{{server.visitDay}}</td>
                        <td>{{server.pageView}}</td>
                        <td>{{server.uniqueVisitor}}</td>
                        <td>{{server.ipNum}}</td>
                        <td >{{server.bounceRate | percentage:2 }}</td>
                        <td >{{server.avgTimeSpent | timeFilter:2 }}</td>
                        <td >{{server.avgVisitPages | number:2 }}</td>
                        <td>{{server.newUniqueVisitor}}</td>
                        <td >{{server.newUniqueVisitorRate | percentage:2 }}</td>
                    </tr>
                    </tbody>
                </table>

function serverService($http){
    this.serverData = {}
    this.vistiDay = function(startDate,endDate,server){
        console.log('$scope.startDate:',startDate);
        var serverUrl = '/server/'+server.serverName+'.json';
        console.log('serverUrl:',serverUrl);
        return $http.get(serverUrl,{
            params: {
                startDate: new Date(startDate).getTime(),
                endDate: new Date(endDate).getTime()
            }
        }).then(function(resp) {
            //console.log('resp',resp.data);
            console.log('resp',resp.data);
            this.serverData = resp.data
            return serverData;
        });
    }

}

I chrome console is  TypeError: Cannot read property 'serverSide' of undefined ,must use resource?
@l-lin
Copy link
Owner

l-lin commented Sep 23, 2015

Duplicate of #439. Will be fixed in the v0.5.1.

@l-lin l-lin closed this as completed Sep 23, 2015
@Torone
Copy link

Torone commented Oct 1, 2015

When will be released the version 0.5.1? Or how can we solve it without this version upgrade? Actually I can not use it.

@l-lin
Copy link
Owner

l-lin commented Oct 1, 2015

There are not a fixed date.
I'll try to release in october.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants