Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ng引导模式将附加类传递到.Modal对话框_Angular_Ng Bootstrap_Ng Bootstrap Modal - Fatal编程技术网

Angular ng引导模式将附加类传递到.Modal对话框

Angular ng引导模式将附加类传递到.Modal对话框,angular,ng-bootstrap,ng-bootstrap-modal,Angular,Ng Bootstrap,Ng Bootstrap Modal,我目前正在angular应用程序中使用一个自定义主题,需要在ngb模式窗口中的“.modal dialog”容器中附加一个css类 根据文档()的规定,只有通过使用以下方法才能为ngb模态窗口本身传递一个类: this.modalService.open(MyModalComponent, { windowClass: 'my-own-styles' }) 有没有一种方法可以在不使用jQuery的情况下将类传递到“.modal dialog”容器?我已经在ng bootstrap库中的moda

我目前正在angular应用程序中使用一个自定义主题,需要在ngb模式窗口中的“.modal dialog”容器中附加一个css类

根据文档()的规定,只有通过使用以下方法才能为ngb模态窗口本身传递一个类:

this.modalService.open(MyModalComponent, { windowClass: 'my-own-styles' })

有没有一种方法可以在不使用jQuery的情况下将类传递到“.modal dialog”容器?

我已经在
ng bootstrap
库中的
modal
组件中查看了代码,但我找不到一个很好的解决方案。无论如何,如果您只想使用该类来设置该组件的某些部分的样式,则可以将该类用于模态窗口,并选择某个作为该窗口子级的类,即:

TS:

{windowClass:'windowClass'}
SCSS:

.windowclass{
.模态对话框{
//要应用的某些样式
}
}
另外,我认为将jQuery与Angular应用程序结合使用不是一个好主意。

请查看该文档的详细信息。秘密在于组件定义的顶部:

要允许样式传递到组件,您需要设置
封装:viewenclosuration.None


一旦您在组件定义中这样做了,您的CSS类就会被选中。例如:
this.modalService.open(MyModalComponent,{windowClass:'my own styles'})

ng引导程序有自己的API,为什么您将其称为使用jQuery的工具。?顺便说一句,如果是出于CSS目的,您可以直接通过标记选择该元素,如[ngb modal window]这与jQuery无关,我刚才提到它是为了不获得使用jQuery设置类的建议。除此之外,我只想在特定的容器上设置/附加一个类,而不必重写主题的现有样式。该类已经存在于主题中,只需放在那里。否则我就得重写它。该类包含用于模式对话框左定位或右定位的样式。似乎没有其他选项可以重写样式。@您所说的Mario是专门为
ng bootstrap
编写的样式吗?主题是为bootstrap 4.5.x编写的,到目前为止,一切看起来都很好。我要应用的类/样式使模态显示在窗口的左侧或右侧。