2016-01-15 22 views
0

我總是在ngRoute模塊中使用ngTable指令。不過,我最近遷移到UI-Router以更好地適應我現在正在開發的項目。ngTable不能用於UI-Router

但由於某種原因,ngTable無法正確使用UI路由器。 表格正常生成,但是設置沒有。 它既不創建標題也不分頁。由於該組也不工作。

我也嘗試手動創建表頭,但我注意到,當我使用值「templates.header」添加屬性「ng-include」時,它會消失。

我已經習慣了以下版本:
ngTable - 1.0.0-beta.9
UI-路由器 - 0.2.15

有人所遇到的這個問題?我無法在任何地方找到解決方案。


的JavaScript:

app.controller("users", function($http, $rootScope, $stateParams, $scope, NgTableParams) { 
    $scope.users = {}; 

    $http({ 
     method: "POST", 
     url: "./controllers/users/read.php", 
     data: { 
      id: $stateParams.id, 
      language_id: $rootScope.globals.language.id 
     } 
    }).success(function(response) { 
     $scope.tableParams = new NgTableParams({ 
      count: 10, 
      sorting: { 
       name: "asc" 
      } 
     }, { 
      dataset: response 
     }); 

     $scope.users = response; 
    }); 
}); 

HTML:

<table ng-table="tableParams" class="table table-bordered table-striped"> 
    <tr ng-repeat="row in $data"> 
     <td data-title="'txt.pages.users.fields.name' | translate" sortable="'name'" width="45%"> 
      {{ row.name }} 
     </td> 
     <td data-title="'txt.pages.users.fields.email' | translate" sortable="'email'" width="45%"> 
      {{ row.email }} 
     </td> 
     <td data-title="'txt.pages.users.fields.actions' | translate" width="10%"> 
      <button ng-click="edit(row.id)" class="btn btn-warning btn-sm"> 
       <icon class="glyphicon glyphicon-edit"></icon> 
      </button> 
      <button ng-click="delete(row)" class="btn btn-danger btn-sm"> 
       <icon class="glyphicon glyphicon-remove"></icon> 
      </button> 
     </td> 
    </tr> 
</table> 

stateProvider:

app.config(function($stateProvider, $urlRouterProvider) { 
    $stateProvider.state("site", { 
     url: "/", 
     views: { 
      "[email protected]": { 
       templateUrl: "./template/site/index/read.html" 
      }, 
      "[email protected]": { 
       templateUrl: "./template/site/home/read.html" 
      } 
     } 
    }).state("cms", { 
     url: "/cms", 
     views: { 
      "[email protected]": { 
       templateUrl: "./template/cms/index/read.html" 
      } 
     } 
    }).state("dashboard", { 
     parent: "cms", 
     url: "/dashboard", 
     views: { 
      "[email protected]": { 
       templateUrl: "./template/cms/dashboard/read.html" 
      } 
     } 
    }).state("login", { 
     parent: "cms", 
     url: "/login", 
     views: { 
      "[email protected]": { 
       templateUrl: "./template/cms/login/read.html" 
      } 
     } 
    }).state("users", { 
     parent: "cms", 
     url: "/users", 
     views: { 
      "[email protected]": { 
       controller: "users", 
       templateUrl: "./template/cms/users/read.html" 
      } 
     } 
    }); 
}); 
+1

請發表相關的代碼示例。在當前狀態下回答你的問題是不可能的。 –

+0

對不起。我完全忘了。 –

+0

請發佈狀態定義。能夠看到如何定義是非常重要的。 –

回答

0

我想你應該在以下行中使用$users代替$data

<tr ng-repeat="row in $data"> 
+0

$ data是ngTable使用的變量。 –