如何在带有SystemJs模块系统的Angular 4应用程序中使用ngx-bootstrap [英] How to use ngx-bootstrap in Angular 4 application with SystemJs module system

查看:105
本文介绍了如何在带有SystemJs模块系统的Angular 4应用程序中使用ngx-bootstrap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了许多指定路径的变体,以允许SystemJS加载ngx-bootstrap软件包

I have tried out many variations of specifying path for allowing SystemJS to load the ngx-bootstrap package

    System.config({
    "defaultJSExtensions": true,
    "paths": {

        "@angular/core": "node_modules/@angular/core/bundles/core.umd.js",
        "@angular/forms": "node_modules/@angular/forms/bundles/forms.umd.js",
        "@angular/http": "node_modules/@angular/http/bundles/http.umd.js",
        ...
        "*": "node_modules/*",
        "ngx-bootstrap": "node_modules/ngx-bootstrap",
        "highcharts": "node_modules/highcharts/highcharts.js",
        "angular2-highcharts": "node_modules/angular2-highcharts/index.js"
    },
    "packages": {}
});

但是仍然无法正确加载..

But still it won't load properly..

我在控制台中看到以下错误

I see following error in the console

"(SystemJS) XHR error (404 Not Found) loading http://localhost:5555/node_modules/ngx-bootstrap.js 

wrapFn@http://localhost:5555/node_modules/zone.js/dist/zone.js?1493823577322:1230:30 [<root>]       

Error loading http://localhost:5555/node_modules/ngx-bootstrap.js as "ngx-bootstrap" from http://localhost:5555/hc/app.module.js" 

"Not expecting this error? Report it at https://github.com/mgechev/angular-seed/issues"

推荐答案

您缺少此部分:

packages: {
  //... other code
  'ngx-bootstrap': { format: 'cjs', main: 'bundles/ngx-bootstrap.umd.js', defaultExtension: 'js' },
}

此处的演示: https://github .com/valor-software/angular2-quickstart/blob/e9ea3dfd6ea48acf40a99e8e0ab1c9908f3467cd/systemjs.config.js#L22

这篇关于如何在带有SystemJs模块系统的Angular 4应用程序中使用ngx-bootstrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆