[Ionic 2 feature] Overlays (Alert, Popover): cssClass option with support for multiple classes
For a better and more flexible styling of my alert and popover overlays I would like to have the cssClass option supporting multiple classes. That could be in the form of concatenated class names or as an array of class names.
Now the cssClass supportes only one string token, any space character within results in runtime exceptions (InvalidCharacterError).
So cssClass="class-1 class-2" or cssClass=['class-1', 'class-2'] would be ideal.
Platform: Ionic 2 beta.11
Thank you!
You currently can pass multiple classes, like so:
doAlert() {
let alert = this.alertCtrl.create({
title: 'Alert',
subTitle: 'Subtitle',
message: 'This is an alert message.',
buttons: ['OK'],
cssClass: 'my-alert another-class'
});
alert.present();
}
This should probably be documented better though. How are you currently trying to pass it?
Thank you for looking into it. I only tried it with a Popover and
cssClass: "infopage mytheme"
which produces the following exception at runtime:
EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./PopoverCmp class PopoverCmp_Host - inline template:0:0
ORIGINAL EXCEPTION: InvalidCharacterError: Failed to execute 'add' on 'DOMTokenList': The token provided ('infopage mytheme') contains HTML space characters, which are not valid in tokens.
....
I just checked my Alerts and they do fine with multiple classes, as you said. So this seems to be an Popover issue only.
Thanks! I have added support for multiple classes to be passed to Popover, Action Sheet, Loading, and Toast components. It was already supported for the Alert and Picker components. I published a nightly version if you would like to test it out:
npm install --save [email protected]
Nice, thank you! Now it works as expected, and I can declutter my SCSS...
Awesome. I updated the documentation to reflect this. It will be in the beta 12 release. :)
Hey, How about modals?
how update the alert color with ionic 2 ??
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.