Ng网格不从子路由渲染

时间:2014-09-22 18:00:02

标签: angularjs ng-grid

我尝试在用作子路线时渲染ng网格,但在点击时没有任何渲染

路线2的展示列表链接。

这里的掠夺者:http://plnkr.co/edit/JGmqFj

不确定我做错了什么。



var myapp = angular.module('myapp', ["ui.router"])
    myapp.config(function($stateProvider, $urlRouterProvider){
      
      // For any unmatched url, send to /route1
      $urlRouterProvider.otherwise("/route1")
      
      $stateProvider
        .state('route1', {
            url: "/route1",
            templateUrl: "route1.html"
        })
          .state('route1.list', {
              url: "/list",
              templateUrl: "route1.list.html",
              controller: function($scope){
                $scope.items = ["A", "List", "Of", "Items"];
              }
          })
          
        .state('route2', {
            url: "/route2",
            templateUrl: "route2.html"
        })
          .state('route2.list', {
              url: "/list",
              templateUrl: "route2.list.html",
              controller: function($scope){
                $scope.things = [{name:"Lucy", number:23}, {name:"Morgan", number:44}];
                $scope.gridOptions = {
                  data: 'things',
                  multiSelect: false,
                  columnDefs: [
                      { field: 'name', displayName: 'Name', width: 190 },
                      { field: 'number', displayName: 'Number', width: 190 },                      
                  ]
              };
                
              }
          })
    })




1 个答案:

答案 0 :(得分:0)

你忘了注入ngGrid,试试这个:

var myapp = angular.module('myapp', ["ui.router", "ngGrid"])

您应该添加以下CSS代码段来定义网格的大小:

.gridStyle {
    border: 1px solid rgb(212,212,212);
    width: 400px; 
    height: 300px
}