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> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |