1、如果ngFor 或者 ngIf等指令不识别,请在路由中引入,且加入
import { CommonModule } from '@angular/common';
@
NgModule中
imports:[
CommonModule
]
import { BsDropdownModule }
from
'ngx-bootstrap/dropdown';
3、ngbModal open()参数传递
子页面
import { Component, Output, EventEmitter } from '@angular/core'; export class AppModalComponent { private data: string; @Output emitService = new EventEmitter(); constructor() { this.data = "hello world"; }
ngOnInit(){
// 坑,父传子的数据,在init中可以获取, constructor()无法获取
} addMe() { this.emitService.next(this.data) } }
父页面
openModal() { const modalRef = this.modalService.open(AppModalComponent);
// 父传子
modalRef.componentInstance.data = 'hi';
// 子传父: modalRef.componentInstance.emitService.subscribe((emmitedValue) => { // do sth with emmitedValue }); }