2016-03-04 78 views
0

我试图在VS项目中导入ng2-bootstrap模块。 我拿这个github repo,它在将"moment": "2.11.2"加到tsconfig.json之后成功启动。visual studio 2015中的ng2-bootstrap模块

在VS我做的差不多,把"ng2-bootstrap": "1.0.5", "moment": "2.11.2"加到tsconfig.json,VS恢复到Dependencies。然后用gulp我将ng2-bootstrap.min.js, moment.js移动到根应用程序目录,并将其绑定到index.htmlmoment.js map.in system.js配置为map: { moment: 'libs/moment.js }

添加Alert组件到我的角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>到我index.htmldate-formatter.ts声明变量等declare var moment: any,错误消失,但建立后引导tags没有任何效果。

Project Solution Structure

而在神秘的方式我被编译node_modules/ng2-bootstrap和我所有的ts文件wwwroot/app/scripts目录。我用wwwroot/app/替换编译的js文件,但它也没有效果。我的应用程序没有看到ng2-bootstrap组件的本机属性。也许有人遇到这种问题?

回答

0

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

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