简体   繁体   English

数据放置在Angular UI网格之外

[英]Data placed outside of Angular ui-grid

We have plenty of server-side data grid controls, would like to replace them w/ generic clientside Angular. 我们有很多服务器端数据网格控件,希望将它们替换为通用客户端Angular。 But data is always placed outside of the grid. 但是数据总是放在网格之外。 To find out the cause, I followed the official demo/tutorial , combine .js and .css into local.html, still the same result. 为了找出原因,我遵循了官方的演示/教程 ,将.js和.css合并为local.html,结果仍然相同。 enter image description here 在此处输入图片说明

Visual Studio 2015 w/ Update, NuGet installed ui-grid(v3.2.9 - 2016-09-21). 带更新的Visual Studio 2015,已安装NuGet ui-grid(v3.2.9-2016-09-21)。 Must be something missing or the demo has problem. 必须缺少某些内容,否则演示有问题。

Here is local.html: 这是local.html:

<!doctype html>
<html ng-app="app">
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-touch.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/csv.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/pdfmake.js"></script>
    <script src="http://ui-grid.info/docs/grunt-scripts/vfs_fonts.js"></script>
    <script src="/Scripts/ui-grid.js"></script>
    <script src="/Content/ui-grid.css"></script>

    <style>
        .grid {  width: 500px;  height: 250px;}
    </style>

    <script>
        var app = angular.module('app', ['ngTouch', 'ui.grid']);

        app.controller('MainCtrl', ['$scope', function ($scope) {

            $scope.myData = [
              {
                  "firstName": "Cox",
                  "lastName": "Carney",
                  "company": "Enormo",
                  "employed": true
              },
              {
                  "firstName": "Lorraine",
                  "lastName": "Wise",
                  "company": "Comveyer",
                  "employed": false
              },
              {
                  "firstName": "Nancy",
                  "lastName": "Waters",
                  "company": "Fuelton",
                  "employed": false
              }
            ];
        }]);
    </script>
</head>
<body>
    <div ng-controller="MainCtrl">
        <div id="grid1" ui-grid="{ data: myData }" class="grid"></div>
    </div>
</body>
</html>

Stupid me, I was loading .css using tag. 愚蠢的我,我正在使用标签加载.css。 So this line 所以这条线

<script src="/Content/ui-grid.css"></script>

should be this instead: 应该是这样的:

<link rel="stylesheet" type="text/css" href="/Content/ui-grid.css">

It's been working as expected. 它一直按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM