简体   繁体   English

Angular CLI-带有ng-boostrap的angular 5.2.0无法正常工作

[英]Angular CLI - angular 5.2.0 with ng-boostrap is not working

I am trying to setup angular application with angular cli and there is a new ng-boostrap module specifically for angular application 我正在尝试使用角度cli设置角度应用程序,并且有一个专门用于角度应用程序的新ng-boostrap模块

ng new angular-cli-bootstrap-test
cd angular-cli-bootstrap-test

npm install --save @ng-bootstrap/ng-bootstrap
ng serve

and adding few configurations for ng-boostrap, app.module.ts : 并为ng-boostrap, app.module.ts添加了一些配置:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule } from '@angular/forms';

import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    NgbModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts : app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  model = {
    left: true,
    middle: false,
    right: false
  };
}

app.component.html : app.component.html

<div class="btn-group btn-group-toggle">
  <label class="btn-primary" ngbButtonLabel>
    <input type="checkbox" ngbButton [(ngModel)]="model.left"> Left (pre-checked)
  </label>
  <label class="btn-primary" ngbButtonLabel>
    <input type="checkbox" ngbButton [(ngModel)]="model.middle"> Middle
  </label>
  <label class="btn-primary" ngbButtonLabel>
    <input type="checkbox" ngbButton [(ngModel)]="model.right"> Right
  </label>
</div>
<hr>
<pre>{{model | json}}</pre>

Sorry if I missed something, everything is being displayed without any errors but without bootstrap styles, maybe I am missing something? 抱歉,如果我错过了某些东西,那么所有内容都将正确显示,而且没有引导样式,也许我缺少了什么?

page source form browser: 页面源表单浏览器:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>AngularCliBootstrapTest</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
  <app-root></app-root>
<script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
</html>

Adding css solved my problem, which is not defined in ng-boostrap manual 添加CSS解决了我的问题,这在ng-boostrap手册中未定义

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>AngularCliBootstrapTest</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

</head>
<body>
  <app-root></app-root>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular NG-Boostrap中的DatePicker - DatePicker in Angular NG-Boostrap 带有 ng-boostrap 和 Angular 2 的旋转木马动画 - Animation for carousel with ng-boostrap and Angular 2 将ng-boostrap添加到Angular应用不会对HTML控件产生影响 - Adding ng-boostrap to Angular app makes no effect on HTML controls Angular 4:如何使用ng-boostrap api制作动态标签 - Angular 4: How to make dynamic tabs using ng-boostrap api 无法使用 Angular 和对等 js 安装 ng-boostrap - Can't intall ng-boostrap with Angular and peer js 使用自定义 angular 指令扩展 ng-boostrap 弹出框组件 - Extend ng-boostrap popover component with custom angular directive ng-boostrap不起作用如果&#39;ngb-xx&#39;是Angular组件,则请验证它是否是此模块的一部分 - ng-boostrap not workingIf 'ngb-xx' is an Angular component, then verify that it is part of this module 为什么所有Angular 2 ng-boostrap模态代码都必须位于app.module.ts的顶部? - Why does all Angular 2 ng-boostrap Modal code have to be at top in app.module.ts? 移动鼠标时,带有嵌入式视频的ng-boostrap模态将重新加载 - Angular ng-boostrap modal with an embeded video reloads when mouse is moved ng-boostrap:ESC 按键上的模式关闭不起作用 - ng-boostrap : modal dismiss on ESC keypress not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM