Comments (18)
How do I set a custom class on the modal-dialog element?
from ngx-modialog.
It should look like this
modal.alert()
.headerClass('modal-header')
.title('Hello World')
.body('A Customized Modal')
.bodyClass('modal-body')
.footerClass('modal-footer')
.okBtnClass('btn')
.open();
Play with the generator to see other options... http://shlomiassaf.github.io/angular2-modal#/customizeModals
from ngx-modialog.
Basically there is a 1 custom modal that I'v implemented (MessageModal) which represents a classic bootstrap modal - it replace the old ones (okOnly, yesNo)
I've built the alert,prompt and confirm presets around it which provides a lot of flexibility.
If a more advanced scenario is needed a custom modal is needed...
When I think about it, its quite generic because you can build your own modal + presets and have a modal supporting something other then bootstrap
from ngx-modialog.
I'm aware of the headerClass, bodyClass and footerClass, but that will not allow you to do any positioning. That why I wanted to see a way to add a class to the modal-dialog. It could be an optional .modalClass('my-custom-modal')
in the fluent api
from ngx-modialog.
The problem with modal-dialog is that it hold the "size" css class.
So, What would you think is the best approach here?
Template:
`<div class="modal-dialog"
[class.modal-lg]="dialogInstance.config.size == \'lg\'"
[class.modal-sm]="dialogInstance.config.size == \'sm\'">
<div class="modal-content" (click)="onContainerClick($event)" style="display: block">
<div style="display: none" #modalDialog></div>
</div>
</div>`
So having a custom css class should override the size, which then creates a weird behaviour...
from ngx-modialog.
Doing something like this will not override the size class
<div class="modal-dialog"
[ngClass]="dialogInstance.config.modalDialogClass || ''"
[class.modal-lg]="dialogInstance.config.size == \'lg\'"
[class.modal-sm]="dialogInstance.config.size == \'sm\'">
<div class="modal-content" (click)="onContainerClick($event)" style="display: block">
<div style="display: none" #modalDialog></div>
</div>
</div>
from ngx-modialog.
Yep I agrre but that doesn't solve my issue.
config.size
has a default value, usually "lg".
So a user will have to do
modal.alert()
.size('')
.modalDialogClass('something')
.open()
To get the class to be what he wanted...
Maybe setting modalDialogClass will also override size?
from ngx-modialog.
You know what, overriding make's sense, if someone wants to be explicit then by all means, all the way.
from ngx-modialog.
There should be room for both. In my current setup I use both lg
and a custom class. The custom class is currently used to positioning the modal not changing its size.
Btw. don't know if modalDialogClass
would be the best fit for a name. What about modalClass
to keep it aligned with the headerClass
from ngx-modialog.
If u'r setting a custom modal-dialog class you will need to set "modal-lg" as a custom class.
e.g: modal.alert().dialogClass('my-cutom modal-lg')
I think it looks better then modal.alert().dialogClass('my-cutom').size('')
from ngx-modialog.
Btw. don't know if modalDialogClass would be the best fit for a name. What about modalClass to keep it aligned with the headerClass
The naming convention is xClass where x is the original class name without the modal (modal-x).
e.g: modal-header -> headerClass
So it will be dialogClass
from ngx-modialog.
Makes sense
from ngx-modialog.
BTW, you know that all xClass methods override the class, so setting dialogClass
will remove the original class (modal-dialog), if it's addition you're after you will have to do modal-dialog my-css
There's no other option...
from ngx-modialog.
I'm not seeing that behaviour using beta12.
When I'm using [ngClass]="dialogInstance.config.modalDialogClass || ''"
I get the value from the config added to the class list. My modal-dialog ends of with the following class list: modal-dialog lg custom
from ngx-modialog.
I talked about general behaviour of xClass in the preset's.
As for the expression dialogInstance.config.modalDialogClass
it invalid because dialogInstance.config
is not the preset API, it's an instance of ModalConfig
which is build from the preset, but it's not the preset so dialogInstance.config.modalDialogClass
will always be null.
The actual preset is injected into the Modal component itself.
The preset is wrapper that combine's the two, but when doing a manual implementation they are separate.
from ngx-modialog.
Okay, I misunderstood. Btw. the dialogInstance.config.modalDialogClass
is just something I have in a local fork - switching to your new fluent api version when the dialogClass is implemented.
from ngx-modialog.
Cool 👍
It will probably end up (dialogClass) on the config object since it's a level above the modal component...
from ngx-modialog.
See latest commits, modal-dialog is enabled via dialogClass
You can verify it in the code generator.
If size
is set it will not remove it, I left it as you requested originally
npm version 0.1.1
from ngx-modialog.
Related Issues (20)
- ngx-modialog vex className have no effect HOT 1
- BSModalContext not found in ngx-modialog/plugins/bootstrap HOT 1
- IE flickering bug
- can't used in service(angular5)
- Version 5.0.1 breaks Angular 5 support HOT 10
- Is ngx-modialog support in angular6 ?
- Site Documentation link opens site in child window.
- defaultViewContainer does not exist in ngx-modialog 3.x and higher HOT 1
- ngx-modal doesn't work with Angular 6 HOT 1
- It doesn't work with Angular 6 .................................. HOT 4
- Dialog doesn't open after update to Angular 6 HOT 2
- Modals not working in Bootstrap 4.1.3
- Cannot build production verions of library
- Update to Angular 7
- Modal not rendering template in multiple tabs
- Angular 8 HOT 2
- Possibility to move the modals HOT 1
- Does this package is supported in Angular 9 HOT 6
- Property 'then' does not exist on type 'DialogRef<TwoButtonPreset>'.ts(2339) HOT 1
- Generic type 'ModuleWithProviders<T>' requires 1 type argument(s)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-modialog.