如何编译,构建,运行ng2-bootstrap-development?

时间:2017-02-08 21:13:19

标签: angular typescript angular-cli ng2-bootstrap

ng2-bootstrap-development不能为我编译。我在那里看到了angular-cli,但当我跑ng serve时,我得到You have to be inside an angular-cli project in order to use the serve command.我错过了什么?

2 个答案:

答案 0 :(得分:0)

我发现如果您想与angular-cli一起使用,则必须执行以下步骤:

npm i -g angular-cli
ng new my-app
cd my-app
ng serve

添加ng2-bootstrap

现在安装ng2-bootstrap和bootstrap

npm install ng2-bootstrap bootstrap --save

打开src/app/app.module.ts并添加

import { AlertModule } from 'ng2-bootstrap';
...

@NgModule({
...
 imports: [AlertModule.forRoot(), ... ],
 ... 
})

现在打开angular-cli.json并在样式数组中插入一个新条目

"styles": [
  "styles.css",
  "../node_modules/bootstrap/dist/css/bootstrap.min.css"
],

现在打开src/app/app.component.html并添加

<alert type="success">hello</alert>


来源

https://github.com/valor-software/ng2-bootstrap/blob/development/docs/getting-started/ng-cli.md

答案 1 :(得分:0)

以下是使用virtualenv运行和提供ng2-bootstrap演示的方法。礼貌我可靠的同事。

cd ~
mkdir test
cd test
virtualenv venv
source venv/bin/activate
pip install nodeenv
nodeenv -p

git clone https://github.com/valor-software/ng2-bootstrap.git
cd ng2-bootstrap

npm install -g angular-cli
npm install
npm run demo.serve