首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Angular 2 ng2-bootstrap datepicker systemjs 404错误

Angular 2 ng2-bootstrap datepicker systemjs 404错误
EN

Stack Overflow用户
提问于 2016-06-13 03:01:49
回答 1查看 845关注 0票数 0

我使用的是ng2-bootstrap中的datepicker。

https://valor-software.com/ng2-bootstrap/#/datepicker

我已经在组件中导入了DATEPICKER_DIRECTIVES

代码语言:javascript
复制
import { DATEPICKER_DIRECTIVES } from './../../../node_modules/ng2-bootstrap/components/datepicker';

已将其添加到指令列表

代码语言:javascript
复制
directives: [DATEPICKER_DIRECTIVES],

然后在我的模板中,我像这样使用它:

代码语言:javascript
复制
<datepicker [(ngModel)]="dt" [minDate]="minDate" [showWeeks]="true"></datepicker>

我的systemjs配置如下所示:

代码语言:javascript
复制
var map = {
        'app': 'content/app',
        'rxjs': 'node_modules/rxjs',
        '@angular': 'node_modules/@angular',
        "angular2-masonry": "node_modules/angular2-masonry",
        'datepicker': 'node_modules/ng2-bootstrap/components/datepicker'
    };

var paths = {
        "masonry-layout": "node_modules/masonry-layout/dist/masonry.pkgd.js",
        'datepicker': 'node_modules/ng2-bootstrap/components/datepicker/datepicker.component.js',
    };


var packages = {
        'app': { main: 'main.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        "angular2-masonry": { defaultExtension: 'js', main: "index" },
        'datepicker': { defaultExtension: 'js', main: "datepicker.component" }
    };

var angularPackages = [
    '@angular/common',
    '@angular/compiler',
    '@angular/core',
    '@angular/http',
    '@angular/platform-browser',
    '@angular/platform-browser-dynamic',
    '@angular/router'
];

angularPackages.forEach(function (pkgName) {
    packages[pkgName] = {
        main: 'index.js', defaultExtension: 'js'
    };
});


var config = {
        map: map,
        packages: packages,
        paths: paths
    };

    System.config(config);

一切编译都没有任何错误,但当我在浏览器中运行它时,它在控制台中显示以下错误:

代码语言:javascript
复制
/content/node_modules/ng2-bootstrap/components/datepicker 404 (Not Found)

我不确定为什么它仍然在我指定要在node_modules/ng2-bootstrap/components/datepicker.中查找的/content/node_modules/ng2-bootstrap/components/datepicker,中搜索datepicker

EN

回答 1

Stack Overflow用户

发布于 2016-06-13 03:21:58

你必须确保在你的index.html中包含ng2-bootstrap库:

代码语言:javascript
复制
<script src="node_modules/ng2-bootstrap/bundles/ng2-bootstrap.min.js"></script>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37778020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档