加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular-cli创建angular2项目并添加ng2-bootstrap

发布时间:2020-12-17 09:42:51 所属栏目:安全 来源:网络整理
导读:1、首先全局安装angular-cli,并创建项目 npm install -g angular-cling new my-appcd my-app 2、安装ng2-bootstrap和bootstrap npm install ng2-bootstrap bootstrap --save 3、在主模块中导入,需要的模块(src/app/app.module.ts) import { AlertModule

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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读