ag-grid错误无法加载资源ag-grid-ng2 / main.js

时间:2016-04-06 14:06:42

标签: ag-grid

我正在visual studio2015中使用angular2实现ag-Grid 我想实现https://github.com/helix46/ag-grid-angular2-beta-ts

中的示例



import {Component} from 'angular2/core';
import {AgGridNg2} from 'ag-grid-ng2/main';
import {GridOptions} from 'ag-grid/main';

@Component({
    selector: 'agGrid',
    templateUrl: "/partial/agGrid",
    directives: [AgGridNg2]
})
export class agGridComponent {
    constructor() {
        console.log("agGrid Component Start");
    }
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"]</title>

    <environment names="Development">
        <!-- Css -->
        <link rel="stylesheet" asp-href-include="~/css/*.css">
   
        <!-- Js -->
        <script src="~/js/jquery.js"></script>
        <script src="~/js/bootstrap.js"></script>
        <script src="~/js/system.js"></script>
        <script src="~/js/rx.js"></script>
        <script src="~/js/typescript.js"></script>
        <script src="~/js/angular2/angular2.dev.js"></script>
        <script src="~/js/angular2/angular2-polyfills.js"></script>
        <script src="~/js/angular2/http.dev.js"></script>
        <script src="~/js/angular2/router.dev.js"></script>

        <!--ag-grid-->
   
        <script src="node_modules/ag-grid/dist/ag-grid.js"></script>
    
    </environment>
 
    <environment names="Production">
        <!-- Css -->
        <link rel="stylesheet" asp-href-include="~/css/*.min.css" asp-append-version="true">
        <!-- Js -->
        <script src="~/js/jquery.min.js"></script>
        <script src="~/js/bootstrap.min.js"></script>
        <script src="~/js/system.min.js"></script>
        <script src="~/js/rx.min.js"></script>
        <script src="~/js/typescript.min.js"></script>
        <script src="~/js/angular2/angular2.dev.min.js"></script>
        <script src="~/js/angular2/angular2-polyfills.min.js"></script>
        <script src="~/js/angular2/http.dev.min.js"></script>
        <script src="~/js/angular2/router.dev.min.js"></script>
        <!--ag-grid-->
        <script src="~/js/ag-grid.js"></script>
    </environment>

    <!-- Configure SystemJS -->
    <script>
            System.config({
                packages: {
                    app: {
                        format: 'register',
                        defaultExtension: 'js'
                    },
                    'ag-grid-ng2': {
                        defaultExtension: "js"
                    },
                    'ag-grid': {
                        defaultExtension: "js"
                    },
                    'ag-grid-enterprise': {
                        defaultExtension: "js"
                    }
                },
                map: {
                    'ag-grid-ng2': 'node_modules/ag-grid-ng2',
                    'ag-grid-enterprise': 'node_modules/ag-grid-enterprise',
                    'ag-grid': 'node_modules/ag-grid'
                }
            });
            System.import('app/boot')
                  .then(null, console.error.bind(console));
    </script>
</head>
<base href="/" />
<body>
    <div>
        @RenderBody()
    </div>
</body>
</html>
&#13;
&#13;
&#13;

但无法加载Failed to load resource: the server responded with a status of 404 (Not Found) ag-grid-ng2/main.js

在node_module中,我给出了正确的路径,但它仍然显示unable to load resource。这是一个错误的快照。 ag-grid error message 请帮我解决这个问题。

感谢你

1 个答案:

答案 0 :(得分:1)

你错过了:

'ag-grid-ng2': 'node_modules/ag-grid-ng2',

var map = {
    'ag-grid': 'node_modules/ag-grid',
    'ag-grid-ng2': 'node_modules/ag-grid-ng2',
};