Angular 仅使用X标记移除模态
目标: 您应该仅通过使用X标记关闭模式,而不是在模式外部单击 问题: 当我尝试使用语法代码[config]=“{background:'static'}”时,我不知道如何解决它 信息:Angular 仅使用X标记移除模态,angular,visual-studio-code,ngx-bootstrap,Angular,Visual Studio Code,Ngx Bootstrap,目标: 您应该仅通过使用X标记关闭模式,而不是在模式外部单击 问题: 当我尝试使用语法代码[config]=“{background:'static'}”时,我不知道如何解决它 信息: 我是新来的 使用VS代码和ngx引导 这是一个复制问题的例子 谢谢大家! BsModalService上的show方法将config对象作为第二个参数。您可以在此处指定背景选项: 在这里,尝试一下: import { Component, TemplateRef } from '@angular/core'; i
谢谢大家!
BsModalService
上的show
方法将config
对象作为第二个参数。您可以在此处指定背景选项:
在这里,尝试一下:
import { Component, TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent{
modalRef: BsModalRef;
config = {
backdrop: true,
ignoreBackdropClick: true
};
constructor(private modalService: BsModalService) {}
person:any={}
openModal(template: TemplateRef<any>) {
this.modalRef = this.modalService.show(template, this.config);
}
openModalWithComponent() {
this.modalRef = this.modalService.show(ModalContentComponent);
this.modalRef.content.title = 'Modal with component';
}
}
/* This is a component which we pass in modal*/
@Component({
selector: 'modal-content',
template: `
<div class="modal-header">
<h4 class="modal-title pull-left">{{title}}</h4>
</div>
<div class="modal-body">
<input type="text" placeholder="Last Name">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" >Save Last Name</button>
</div>
`
})
export class ModalContentComponent {
title: string;
constructor(private modalService: BsModalService) {}
}
从'@angular/core'导入{Component,TemplateRef};
从“ngx引导/模式”导入{BsModalService};
从“ngx引导/modal/bs-modal-ref.service”导入{BsModalRef};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent{
modalRef:BsModalRef;
配置={
背景:没错,
ignoreBackdropClick:true
};
构造函数(私有modalService:BsModalService){}
人物:any={}
OpenModel(模板:TemplateRef供您参考
BsModalService
上的show
方法将config
对象作为第二个参数。您可以在其中指定背景选项:
在这里,尝试一下:
import { Component, TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent{
modalRef: BsModalRef;
config = {
backdrop: true,
ignoreBackdropClick: true
};
constructor(private modalService: BsModalService) {}
person:any={}
openModal(template: TemplateRef<any>) {
this.modalRef = this.modalService.show(template, this.config);
}
openModalWithComponent() {
this.modalRef = this.modalService.show(ModalContentComponent);
this.modalRef.content.title = 'Modal with component';
}
}
/* This is a component which we pass in modal*/
@Component({
selector: 'modal-content',
template: `
<div class="modal-header">
<h4 class="modal-title pull-left">{{title}}</h4>
</div>
<div class="modal-body">
<input type="text" placeholder="Last Name">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" >Save Last Name</button>
</div>
`
})
export class ModalContentComponent {
title: string;
constructor(private modalService: BsModalService) {}
}
从'@angular/core'导入{Component,TemplateRef};
从“ngx引导/模式”导入{BsModalService};
从“ngx引导/modal/bs-modal-ref.service”导入{BsModalRef};
@组成部分({
选择器:“我的应用程序”,
templateUrl:“./app.component.html”,
样式URL:['./app.component.css']
})
导出类AppComponent{
modalRef:BsModalRef;
配置={
背景:没错,
ignoreBackdropClick:true
};
构造函数(私有modalService:BsModalService){}
人物:any={}
OpenModel(模板:TemplateRef供您参考