Json没有正确加载,它有时加载,有时不加载

时间:2015-11-09 12:32:52

标签: angularjs angular-ui-grid

我有一个运行angularJS的页面。有时,当我打开文档时,有时只显示需要显示的数据。当我不断尝试刷新页面时,它几乎是随机的:有时会出现内容,有时则不然。

运行此代码的代码部分如下所示:

<div ng-controller="userAdminConfigCtrl">
  <div ui-grid="adminConfigGridOptions"></div>
</div>

这是上面的html代码的角度。正如你所看到的,在这个角度我用json来显示我的数据

rsBaseApp.controller('userAdminConfigCtrl', [
'$scope', function ($scope) {
    'use strict';


    $scope.adminConfigGridOptions = {
        enableSorting: true,
        columnDefs: [
            { field: 'Username', displayName: 'Username' },
            { field: 'Password', displayName: 'Password' },
            { field: 'PermissionsUsergroups', displayName: 'PermissionsUsergroups' },
            { field: 'other', displayName: 'Other', cellTemplate: '<input type="checkbox">' }

        ]
    };

    $scope.myData = [
      { Username: 'Giacomo Guilizzoni Founder & CEO', Password: '37', PermissionsUsergroups: 'Peldi', other: true },
      { Username: 'Marco Botton Tuttofare', Password: '34', PermissionsUsergroups: 'Patata', other: true },
      { Username: 'Mariah Maclachlan Better Half', Password: '37', PermissionsUsergroups: 'Peldi', other: true },
      { Username: 'Valerie Liberty Head Chef', Password: '554', PermissionsUsergroups: 'Val', other: true },
      { Username: 'Guido Jack Guilizzoni', Password: '6', PermissionsUsergroups: 'The Guids', other: true }
    ]

      $scope.adminConfigGridOptions.data = $scope.myData;
  }

]);

0 个答案:

没有答案