0

我在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>

但无法加载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 错误消息 请帮我解决这个问题。

感谢您

4

1 回答 1

1

你错过了:

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

IE

var map = {
    'ag-grid': 'node_modules/ag-grid',
    'ag-grid-ng2': 'node_modules/ag-grid-ng2',
};
于 2016-09-01T21:12:26.687 回答