question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

*swalPartial does not override <swal> content

See original GitHub issue

Hi there, how do I replace the content of the popup to use the angular 2 syntax ? Let’s say I have this:

    <swal #PagesPopUp
          type="question"
          showCancelButton = "true"
          (confirm)="Save()"
          confirmButtonText='Save'>
        <form *swalPartial>
        </form>
        <ng-container *swalPartial="swalTargets.title">
            Tile Replace with this ({{ title }})
        </ng-container>
        <ng-container *swalPartial="swalTargets.content">
            <h1> Shoild it replace the content? {{ content }}</h1>
        </ng-container>
    </swal>

As you see, I add *swalPartial=“swalTargets.content” to replace the content. but It doesn’t work

Also, how do I call a SwalPartialDirective from the typescript code? right now I use PagesPopUp.show() and I don’t know if this is the right way to do it

Thanks,

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
toveruxcommented, Nov 24, 2017

Okay, I’ve found the cause of that. You can workaround for now by setting text="this won't be displayed" on your <swal>, and you partial view will display.

I’ll come with a proper fix as soon as I have a good one (and time to code it) and ping you when I release a version. Thanks a lot for reporting!

1reaction
toveruxcommented, Jan 27, 2018

Finally got a little time to look at the library again… and well, problem solved without any intervention on my side 😄 Due to recent changes in SweetAlert2 7.4.0, this is no longer an issue. SweetAlert2 changes a few things in its DOM, and now it does not interfere with ngx-sweetalert2 anymore.

However, the behaviour has changed a little. Before, the content target was targeting the DOM element for the text of the modal, and inherited its style. Now, the same target points to the content between the title and the action buttons, where the text is contained (it’s a child element of it). This means that you won’t inherit the text styles from SweetAlert2 anymore (ie. centered text, this is the only style that Swal defines for now). You’ll have to fix that in your own CSS, or you can end up with this:

image

It’s an unwanted “regression” and breaking change in SweetAlert2 7.4.0, but it’s better like that. content now really targets the modal content, not just the text zone.

To mimic the old behaviour again:

.swal-text {
    text-align: center;
}
<div class="swal-text" *swalPartial="swalTargets.content">
    Not-so-broken text
</div>

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

@toverux/ngx-sweetalert2 - npm
Add the [swal] attribute to an element to show a simple modal when that element is clicked. To define the modal contents, you...
Read more >
SweetAlert2 - How to change title and text color?
Try using customClass in the SWAL configuration to give a custom class name to the title or the container and provide the text...
Read more >
@sweetalert2/ngx-sweetalert2: Versions | Openbase
If you change @Input s of a <swal> component while it's opened, the modal will be updated, meaning that you can now have...
Read more >
Sweet Alert - Common Style Inventory
A warning message, with a function attached to the "Confirm"-button... Try me! swal({ title: "Are you sure?", text: "You will not be able ......
Read more >
Guides - SweetAlert
With this format, we can specify many more options to customize our alert. For example we can change the text on the confirm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found