入力がOKのときにsaveを使用してコンポーネントのブートストラップモーダルを閉じます。 私はthisソリューションを試みたが、私はエラーを次取得角度V2.4.1とng-bootstrap 1.0.0-alpha.19Angular2 ng-bootstrapモーダルがコンポーネント内にあります
を使用しています:
No provider for ViewContainerRef
は、私は私のmodule.tsにViewContainerRefを追加しようとしましたが、私はエラーを次取得します:ここで
Type 'typeof ViewContainerRef' is not assignable to type '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();
}
}
}
constructor(public modalRef: NgbModalRef) {}
public closeModal() {
this.modalRef.close();
this.modalRef.dismiss();
}
などを使用しようとした。しかし、これはまったく機能していません。私はエラーメッセージを受け取っていません。
あなたngModuleでNgbModuleを追加しましたか? – Habeeb
はい私は@ NgModule()のインポートで "NgbModule.forRoot()"を追加します – trololololol