我正在尝试在 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.html
并moment.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.ts
declare var moment: any
tags
并且以一种神秘的方式,我被编译node_modules/ng2-bootstrap
并且我的所有ts
文件都在wwwroot/app/scripts
目录中。我替换了编译的js
文件wwwroot/app/
,它也没有效果。我的应用程序看不到ng2-bootstrap
组件的本机属性。也许有人面临这种问题?