1、首先全局安装angular-cli,并创建项目
npm install -g angular-cli ng new my-app cd my-app
2、安装ng2-bootstrap和bootstrap
npm install ng2-bootstrap bootstrap --save
3、在主模块中导入,需要的模块(src/app/app.module.ts)
import { AlertModule } from 'ng2-bootstrap'; ... @NgModule({ ... imports: [AlertModule.forRoot(),... ],... })
只要在模块总导入,不需要在组建中添加,很方便。
4、在angular-cli.json中配置样式文件
"styles": [ "styles.css","../node_modules/bootstrap/dist/css/bootstrap.min.css" ]
5、 在模板中调用 src/app/app.component.html
<alert type="success">hello</alert>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。