打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
003Angular2中使用ng

1、检查@angular/cli版本
  命令行ng -v ,版本号必须大于1.0.0-beta.24

2、新建工程
  工程所在目录,命令行ng new my-app --style=scss  带style参数原因:ng-bootstrap要求使用scss

3、安装bootstrap
  cd my-app  进入工程目录
  cnpm install @ng-bootstrap/ng-bootstrap bootstrap@next --save  安装ng-bootstrap和bootstrap

4、添加bootstrap.min.css引用
  工程目录下,打开.angular-cli.json文件,在styles中添加bootstrap.min.css引用
  "styles": [
    "../node_modules/bootstrap/dist/css/bootstrap.min.css",  此行为新添加
     "styles.scss"
   ]

5、src目录下,新建_variables.scss文件

6、在styles.scss文件中添加如下内容
  @import 'variables';
  @import '../node_modules/bootstrap/scss/bootstrap';

7、/src/index.html文件中添加使用BS4标记
  <body>
          <!-- Enable bootstrap 4 theme -->
          <script>window.__theme = 'bs4';</script>
    <app-root> </app-root>
  </body>

8、AppModule类中引用NgbModule
    import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
    @NgModule({
        imports: [
            NgbModule.forRoot()
        ],
    })
    export class AppModule { }
9、添加模板

  在app.component.html中添加如下内容
     <p>
          <ngb-alert type="success" [dismissible]="false">
            <strong>Success!</strong> Good work.
          </ngb-alert>

  </p>

10、验证

  工程目录下,命令行cnpm start启动工程,浏览器中查看结果

11、ng-bootstrap API参考网址

  

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ng-辅助操作
AngularJs学习笔记--bootstrap
在 AngularJS 应用中处理单选框和复选框
拿掉 Bootstrap 使用 SCSS,YiPro2 改版的簡單小心得
AngularJs+bootstrap搭载前台框架
HTML5移动开发的10大移动APP开发框架
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服