0

我正在尝试在 VS 项目中导入 ng2-bootstrap 模块。我获取了这个 github repo并在添加"moment": "2.11.2"tsconfig.json.

在 VS 中我做的几乎一样,添加"ng2-bootstrap": "1.0.5", "moment": "2.11.2"tsconfig.json, VS 恢复到Dependencies. 然后,gulp我移动ng2-bootstrap.min.js, moment.js到根应用程序目录并将其捆绑到system.js 配置中index.htmlmoment.js映射为map: { moment: 'libs/moment.js }.

将警报组件添加到我的 angular 后class

import {Component, OnInit} from 'angular2/core'
import {Router}       from 'angular2/router'
import {HeroService}  from './hero.service'
import {User}         from './user'
import {Alert}        from 'ng2-bootstrap/ng2-bootstrap'

//declare var jwt_decode: any;

@Component({
    selector: 'login',
    templateUrl: 'app/login.component.html',
    styleUrls: ['app/login.component.css', 'app/css/bootstrap.css',   'app/css/styles.css'],
    directives: [Alert]
})

构建后出现以下错误:

Error   TS2307  Build: Cannot find module 'moment'. ASPAngular2Test     E:\Development\C#\ASP.NET\ASPAngular2Test\src\ASPAngular2Test\node_modules\ng2-bootstrap\components\datepicker\date-formatter.ts    1   

我将它<script src="libs/moment.js"></script>插入我的并在likeindex.html 中声明一个变量,错误消失了,但是在 bulding bootstrap之后没有任何效果。date-formatter.tsdeclare var moment: anytags

项目解决方案结构

并且以一种神秘的方式,我被编译node_modules/ng2-bootstrap并且我的所有ts文件都在wwwroot/app/scripts目录中。我替换了编译的js文件wwwroot/app/,它也没有效果。我的应用程序看不到ng2-bootstrap组件的本机属性。也许有人面临这种​​问题?

4

1 回答 1

0

您正在将 ng2-bootstrap 添加到 tsconfig.json?

不应该添加到 package.json 中吗?

于 2017-01-20T08:09:47.277 回答