简体   繁体   English

模块“ AppModule”导入的异常值“ BootstrapModalModule”

[英]Unexpected value 'BootstrapModalModule' imported by the module 'AppModule'

i am using webpack with angular2. 我正在使用angular2的webpack。 it fails while importing bootstrapmodalmodule from ng2-bootstrap-modal at runtime. 在运行时从ng2-bootstrap-modal导入bootstrapmodalmodule时失败。 Reference link is : ng2-bootstrap-modal 参考链接是: ng2-bootstrap-modal

And here's my files : 这是我的文件:

app.module.ts app.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from "@angular/common";
import { BrowserModule } from '@angular/platform-browser';
import { BootstrapModalModule } from 'ng2-bootstrap-modal';
import { ConfirmComponent } from './shared/login/confirm.component';
import { AppComponent }  from './app.component';


@NgModule({
  declarations: [ AppComponent, ConfirmComponent], 
  imports: [ CommonModule, BrowserModule, BootstrapModalModule ], 
  bootstrap: [ AppComponent ]
})
export class AppModule { }

app.component.ts app.component.ts

import { Component } from '@angular/core';
 import { ConfirmComponent } from './shared/login/confirm.component';
 import { DialogService } from "ng2-bootstrap-modal";


@Component({
    selector: 'pm-app',
    templateUrl: './app.component.html'

})
export class AppComponent {
     constructor(private dialogService:DialogService) {}
        showConfirm() {
            let disposable = this.dialogService.addDialog(ConfirmComponent, {
                title:'Confirm title', 
                message:'Confirm message'})
                .subscribe((isConfirmed)=>{
                    //We get dialog result
                    if(isConfirmed) {
                        alert('accepted');
                    }
                    else {
                        alert('declined');
                    }
                });
            //We can close dialog calling disposable.unsubscribe();
            //If dialog was not closed manually close it by timeout
            // setTimeout(()=>{
            //     disposable.unsubscribe();
            // },10000);
        }
 }

confirm.component.ts confirm.component.ts

import { Component } from '@angular/core';
import { DialogComponent, DialogService } from "ng2-bootstrap-modal";


@Component({  selector: 'confirm',
  template: `<div class="modal-content">
                   <div class="modal-header">
                     <button type="button" class="close" (click)="close()" >&times;</button>
                     <h4 class="modal-title">{{title || 'Confirm'}}</h4>
                   </div>
                   <div class="modal-body">
                     <p>{{message || 'Are you sure?'}}</p>
                   </div>
                   <div class="modal-footer">
                     <button type="button" class="btn btn-primary" (click)="confirm()">OK</button>
                     <button type="button" class="btn btn-default" (click)="close()" >Cancel</button>
                   </div>
                 </div>`
})
export class ConfirmComponent extends DialogComponent {
  constructor(dialogService: DialogService) {
    super(dialogService);
  }
  confirm() {
    // we set dialog result as true on click on confirm button, 
    // then we can get dialog result from caller code 
    this.result = true;
    this.close();
  }
}

Can you try to just import ModalModule from Ng2Bootstrap ? 您可以尝试从Ng2Bootstrap导入ModalModule吗?

ModalModule.forRoot(),

it's wokking form me 从我身上醒来

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

相关问题 模块“ AppModule”导入的异常值“ QRCodeModule” - Unexpected value 'QRCodeModule' imported by the module 'AppModule' 模块&#39;AppModule&#39;导入的意外值&#39;[object Object]&#39; - Unexpected value '[object Object]' imported by the module 'AppModule' 错误:意外的值“AngularFireAuth”。 由模块“AppModule”导入 - Error: Unexpected value 'AngularFireAuth'. imported by the module 'AppModule' 模块“AppModule”导入的意外值“AngularFirestore” - Unexpected value 'AngularFirestore' imported by the module 'AppModule' 模块“AppModule”错误导入的意外值“AngularFirestoreDocument” - Unexpected value 'AngularFirestoreDocument' imported by the module 'AppModule' error 模块&#39;AppModule&#39;导入的意外值&#39;ImageUploadModule&#39; - Unexpected value 'ImageUploadModule' imported by the module 'AppModule' Angular - 模块AppModule导入的意外值MatDialog - Angular - Unexpected value MatDialog imported by the module AppModule 模块&#39;AppModule&#39;导入的意外值&#39;MyCustomModule&#39; - Unexpected value 'MyCustomModule' imported by the module 'AppModule' 模块“AppModule”在语法错误处导入的意外值“未定义” - Unexpected value 'undefined' imported by the module 'AppModule' at syntaxError 模块“ AppModule”导入的异常值“ MdlModule” - Unexpected value 'MdlModule' imported by the module 'AppModule'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM