小编tro*_*lol的帖子

Angular2 ng-bootstrap模块在组件中关闭

当输入正常时,我将通过保存关闭组件中的引导模式.我正在使用angular v2.4.1和ng-bootstrap 1.0.0-alpha.19

我试过这个解决方案,但是我得到了以下错误:

没有ViewContainerRef的提供者

我试图将ViewContainerRef添加到我的module.ts但是我收到以下错误:

类型'typeof ViewContainerRef'不能分配给'Provider'类型

这里是我的组件中的代码:

import { Component } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

@Component({
    selector: '[add-name]',
    templateUrl: '../add-name.html'
})

export class MyComponent {   
   public errorMessage: string = '';

   constructor(public modalActive: NgbActiveModal) {}

   public saveNewStuff(name: string) {
        this.errorMessage = '';

        if (name === '' || name === undefined) {
            this.errorMessage = 'some message';
        } else if (this.errorMessage === '') {
            this.modalActive.close();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我还试图用NgbModalRef

  constructor(public modalRef: NgbModalRef) …
Run Code Online (Sandbox Code Playgroud)

modal-dialog ng-bootstrap angular

4
推荐指数
1
解决办法
8340
查看次数

标签 统计

angular ×1

modal-dialog ×1

ng-bootstrap ×1