简体   繁体   English

如何在angular2-meteor1.3项目中使用ng2-bootstrap?

[英]How to use ng2-bootstrap in angular2-meteor1.3 project?

For a new project, I have run those in terminal 对于一个新项目,我已经在终端中运行了

npm init npm初始化

meteor add angular2-compilers 流星添加angular2编译器

meteor remove blaze-html-templates 流星删除blaze-html-templates

meteor npm install --save angular2-meteor 流星npm install --save angular2-meteor

meteor npm install --save meteor-node-stubs 流星NPM安装-保存流星节点存根

meteor npm install --save bootstrap4-webpack-package 流星npm install --save bootstrap4-webpack-package

meteor npm install --save ng2-bootstrap 流星npm install --save ng2-bootstrap

import 'reflect-metadata';
import 'zone.js/dist/zone';
import 'bootstrap4-webpack-package';
import { Component } from 'angular2/core';
import { bootstrap } from 'angular2/platform/browser';
import { Alert } from 'ng2-bootstrap/ng2-bootstrap';

@Component({
  selector: 'app',
  template: `<alert type="info">ng2-bootstrap hello world!</alert>`,
  directives: [Alert]
})
class App { }
bootstrap(App);

Right now bootstrap4-webpack-package makes Bootstrap 4 works, but ng2-bootstrap still not works. 现在bootstrap4-webpack-package使Bootstrap 4可以工作,但是ng2-bootstrap仍然不能工作。

Since I am using Bootstrap 4, so I also tried to add 由于我使用的是Bootstrap 4,因此我也尝试添加

import { Ng2BootstrapConfig, Ng2BootstrapTheme } from 'ng2-bootstrap/ng2-bootstrap';
Ng2BootstrapConfig.theme = Ng2BootstrapTheme.BS4;

But still not works. 但仍然行不通。

It shows the error: 它显示错误:

EXCEPTION: No Directive annotation found on Alert 例外:在警报上找不到指令注释

EXCEPTION: Error: Uncaught (in promise): No Directive annotation found on Alert 例外:错误:未捕获(按承诺):在警报上未找到指令注释

I am not sure whether this is related with this issue . 我不确定这是否与此问题有关

How can I use ng2-bootstrap? 如何使用ng2-bootstrap? Thanks 谢谢

At last I found it is because of my NPM problem. 最后,我发现这是因为我的NPM问题。 Because the code can run well on other people's machine. 因为代码可以在其他人的机器上很好地运行。

I uninstall my NPM, and install the new v5.10.1, the problem fixes! 我卸载了NPM,然后安装了新的v5.10.1,此问题已解决!

Check here for details. 在此处查看详细信息。

Hope this can help people who met similar weird problem. 希望这可以帮助遇到类似奇怪问题的人们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM