angular4-如果我使用Bootstrap4Alpha主题创建项目,是否需要安装ng bootstrap

angular4-如果我使用Bootstrap4Alpha主题创建项目,是否需要安装ng bootstrap,angular,bootstrap-4,Angular,Bootstrap 4,我在angular4中使用SB-Admin-BS4-ANGLANG-4-master主题。 主题已链接到 我想在代码中使用引导模式。 根据主题中的文档,我使用了情态动词 和我以前一样 import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; 在app.module.ts中 然后我不得不通过npm安装ng引导程序,因为它不工作 import {NgbModule} from '@ng-bootstrap

我在angular4中使用SB-Admin-BS4-ANGLANG-4-master主题。 主题已链接到 我想在代码中使用引导模式。 根据主题中的文档,我使用了情态动词

和我以前一样

import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
在app.module.ts中

然后我不得不通过npm安装ng引导程序,因为它不工作

import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
当我安装ngbootstrap时,网页包正在被删除

Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
我根据重新安装了webpack

现在,当我打开使用模式代码的模块时,我遇到了这个错误

 Error: Uncaught (in promise): Error: No provider for NgbModalStack!
injectionError@http://localhost:4200/vendor.bundle.js:58005:90
noProviderError@http://localhost:4200/vendor.bundle.js:58043:12
../../../core/@angular/core.es5.js/</ReflectiveInjector_.prototype._throwOrNull@http://localhost:4200/vendor.bundle.js:59485:19
../../../core/@angular/core.es5.js/</ReflectiveInjector_.prototype._getByKeyDefault@http://localhost:4200/vendor.bundle.js:59524:20
../../../core/@angular/core.es5.js/</ReflectiveInjector_.prototype._getByKey@http://localhost:4200/vendor.bundle.js:59456:20
../../../core/@angular/core.es5.js/</ReflectiveInjector_.prototype.get@http://localhost:4200/vendor.bundle.js:59325:16
resolveNgModuleDep@http://localhost:4200/vendor.bundle.js:66317:12
_createClass@http://localhost:4200/vendor.bundle.js:66363:113
_createProviderInstance$1@http://localhost:4200/vendor.bundle.js:66328:26
resolveNgModuleDep@http://localhost:4200/vendor.bundle.js:66313:17
../../../core/@angular/core.es5.js/</N…
Stack trace:
resolvePromise@http://localhost:4200/polyfills.bundle.js:6634:31
resolvePromise@http://localhost:4200/polyfills.bundle.js:6605:17
scheduleResolveOrReject/<@http://localhost:4200/polyfills.bundle.js:6683:17
../../../../zone.js/dist/zone.js/</</ZoneDelegate.prototype.invokeTask@http://localhost:4200/polyfills.bundle.js:6264:17
onInvokeTask@http://localhost:4200/vendor.bundle.js:60717:24
../../../../zone.js/dist/zone.js/</</ZoneDelegate.prototype.invokeTask@http://localhost:4200/polyfills.bundle.js:6263:17
../../../../zone.js/dist/zone.js/</</Zone.prototype.runTask@http://localhost:4200/polyfills.bundle.js:6031:28
drainMicroTaskQueue@http://localhost:4200/polyfills.bundle.js:6441:25
../../../../zone.js/dist/zone.js/</</ZoneTask.invokeTask@http://localhost:4200/polyfills.bundle.js:6342:21
invokeTask@http://localhost:4200/polyfills.bundle.js:7266:9
globalZoneAwareCallback@http://localhost:4200/polyfills.bundle.js:7284:17
  core.es5.js:1020

ng bootstrap是一系列使用bootstrap4.0.css的小部件。当我们安装ng bootstrap时,我们只需要bootstrap.min.css

npm install --save @ng-bootstrap/ng-bootstrap
我们可以下载bootstrap.min.css,例如,如果我们使用angular cli,则可以修改angular-cli.json中的“样式”标记

"styles": [
        "styles.css",
        "../node_modules/font-awesome/css/font-awesome.css"
      ],
bootstrap是一系列小部件+bootstrap.css。安装bootstrap时,不需要导入bootstrap.min.css

npm install bootstrap@4.0.0-beta.2

它们都有模态

如果您希望模态具有角度,则需要安装
ng bootstrap
。你的主题使用它

在遇到类似问题时,这个
NgbModule.forRoot()
似乎是解决办法

但如果这对您没有帮助,我在您的日志中看到了这个错误
未捕获(承诺中)
。可能正在使用
ModalDismissReasons

在我的项目中,我使用了
NgbModalRef
您可以尝试下面的代码

您的导入看起来像是从“@ng bootstrap/ng bootstrap”导入{NgbModal,NgbModalRef}”

定义
modalReference:NgbModalRef在您的类中
TableinfoComponent

现在,这就是您的
打开(内容)
的外观

open(content) {
    this.modalReference = this.modalService.open(content);
    this.modalReference.result.then((result) => {
      console.log(result);
    });
}
删除所有其他代码,包括
getDismissReason
,然后重试


适合我,希望这对您有所帮助。

您是否尝试过添加引导本身而不是ng引导<代码>npm安装引导程序--保存
?它能与引导程序4一起工作吗?啊,不确定
npm安装引导程序--保存
是否安装了v4,但如果不能,只需指定4thats的beta版本不工作..它能安装引导程序v4 beta吗?我已经在使用SB-Admin-BS4-ANGUAL-4(引导程序主题)我在此主题上创建了新项目我是否需要安装ng bootstrap或ngx bootstrap?我根据问题中提到的bootstrap主题创建了项目,并在其他模块中使用演示模式。我基于alpha版本。您的主题具有
NgbModalStack
但在
ng bootstrap
中尚不受支持。检查此项,请提供你的主题文件linki检查了github repo。您的主题未使用
ng引导
ngx引导
npm install bootstrap@4.0.0-beta.2
open(content) {
    this.modalReference = this.modalService.open(content);
    this.modalReference.result.then((result) => {
      console.log(result);
    });
}