在路由的html页面中没有获得ag-grid

时间:2016-10-18 05:12:40

标签: html angularjs ag-grid

我正在尝试在我的HTML页面 new.html 上获取ag-grid,点击 old.html 页面后,该网页将加载到视图中。 new.html 将通过角度根加载。

old.html 如下:

{
  "name": "Invalid Configuration",
  "message": "Missing required parameter \"connection\" when instantiating \"filsh\\yii2\\oauth2server\\storage\\Mongo\".",
  "code": 0,
  "type": "yii\\base\\InvalidConfigException",
  "file": "/var/www/html/advanced/vendor/yiisoft/yii2/di/Container.php",
  "line": 457,
  "stack-trace": [
    "#0 /var/www/html/advanced/vendor/yiisoft/yii2/di/Container.php(367): yii\\di\\Container->resolveDependencies(Array, Object(ReflectionClass))",
    "#1 /var/www/html/advanced/vendor/yiisoft/yii2/di/Container.php(154): yii\\di\\Container->build('filsh\\yii2\\oaut...', Array, Array)",
    "#2 /var/www/html/advanced/vendor/yiisoft/yii2/di/Container.php(172): yii\\di\\Container->get('filsh\\yii2\\oaut...', Array, Array)",
    "#3 /var/www/html/advanced/vendor/filsh/yii2-oauth2-server/Module.php(80): yii\\di\\Container->get('refresh_token')",
    "#4 /var/www/html/advanced/vendor/filsh/yii2-oauth2-server/controllers/RestController.php(25): filsh\\yii2\\oauth2server\\Module->getServer()",
    "#5 [internal function]: filsh\\yii2\\oauth2server\\controllers\\RestController->actionToken()",
    "#6 /var/www/html/advanced/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)",
    "#7 /var/www/html/advanced/vendor/yiisoft/yii2/base/Controller.php(154): yii\\base\\InlineAction->runWithParams(Array)",
    "#8 /var/www/html/advanced/vendor/yiisoft/yii2/base/Module.php(454): yii\\base\\Controller->runAction('token', Array)",
    "#9 /var/www/html/advanced/vendor/yiisoft/yii2/web/Application.php(87): yii\\base\\Module->runAction('oauth2/rest/tok...', Array)",
    "#10 /var/www/html/advanced/vendor/yiisoft/yii2/base/Application.php(375): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
    "#11 /var/www/html/advanced/api/web/index.php(19): yii\\base\\Application->run()",
    "#12 {main}"
  ]
}

new.html 如下:

<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
    <script src="ag-grid.js"></script>
    <script>
        var module = angular.module("sampleApp", ['ngRoute']);
        module.config(['$routeProvider',
        function($routeProvider) {
            $routeProvider.
                when('/route1', {
                    controller: 'myCtrl',
                    templateUrl: 'new.html'
                }).
                otherwise({
                    redirectTo: '/'
                });
        }]);
        module.controller("myCtrl", function($scope) {
            document.addEventListener('DOMContentLoaded', function() {
                var gridDiv = document.querySelector('#myGrid');
                var gridOptions = {
                    columnDefs: [
                        {headerName: 'Name', field: 'name'},
                        {headerName: 'Role', field: 'role'}
                    ],
                    rowData: [
                        {name: 'Niall', role: 'Developer'},
                        {name: 'Eamon', role: 'Manager'},
                        {name: 'Brian', role: 'Musician'},
                        {name: 'Kevin', role: 'Manager'}
                    ]
                };
                new agGrid.Grid(gridDiv, gridOptions);
            });
        });
    </script>
</head>
<body ng-app="sampleApp">
    <div> 
        <a href="#/route1" role="button">Route</a> 
        <div ng-view></div>
    </div> 
</body>

当我执行 old.html 分别将 myCtrl 控制器代码保留在脚本标记内并使用 new.html 中的函数时,它运行良好并且网格与数据填充一起显示。但在路由视图中,网格未显示。 我想在点击 old.html

中的链接时显示网格

请帮我解决这个问题。感谢。

0 个答案:

没有答案