Comments (9)
You can't without this library :)
If you really don't want it - no questions asked - you can inspirate yourself from swal.directive.ts for the core of the feature, swal-portal-targets.service.ts for the modal query selectors and swal-portal.component.ts for the component that holds the user-provided views, but you may not need this one if you have only that bar-rating use case - in this case you could just put you bar-rating component in your entryComponents and instantiate it in lieu of my SwalPortalComponent
.
from ngx-sweetalert2.
Unfortunately, no, this is not possible for now.
You can effectively pass HTML via the html
option, but this must be normal, standard HTML. You are using the Angular template syntax here.
I cannot either parse it using the Angular Compiler before passing it to SweetAlert2, because production builds of Angular do not embed the JiT compiler.
The solution I see would be to use a template or transclusion, but both require an update of ngsweetalert2.
I will add that to my todo list, but I'm afraid you have to find another solution for now.
I suggest you to programmatically generate a string containing your list, and pass that HTML string to SweetAlert2.
from ngx-sweetalert2.
Did some research over time and still don't know if that's actually possible.
If someone knows how to do that, (s)he's welcome!
from ngx-sweetalert2.
I had the same problem and eventually did the following:
<div class="row video-format-row">
<div class="col-3 video-format-col">
<select class="form-control" [(ngModel)]="selectedVideoFormat">
<option value='3'>mp4</option>
<option value='2'>avi</option>
</select>
</div>
</div>
</span>
swal({
title: "some title",
html: '',
showCancelButton: true,
onOpen: function (val) {
let spanList = val.getElementsByTagName("span");
let swalSpan: HTMLElement;
for (let i = 0; i < spanList.length; i++) {
if (spanList[i].id === "swalSpan") {
swalSpan = spanList[i];
break;
}
}
let picker = document.getElementById('innerRangePicker');
swalSpan.appendChild(picker);
},
onClose: function () {
let picker = document.getElementById('innerRangePicker');
let pickerHolder = document.getElementById('rangePicker');
pickerHolder.appendChild(picker);
}
});
I'm not sure if this is the best solution but that is the best I could think of.
Maybe it can help someone with a similar problem.
from ngx-sweetalert2.
Good news! This is now possible with the v.3 release! https://github.com/toverux/ngx-sweetalert2/releases/tag/v3.0.0
Beware that the package changed name (everything is explained in the release notes).
from ngx-sweetalert2.
how can I use <br>
in text property ?
from ngx-sweetalert2.
You have to use [html]="Hello<br>World"
for that. SweetAlert2 does not allow HTML "by default" (with that text
property) to avoid possible unforeseen security vulnerabilities, ie. your alerts display user-defined content that is not sanitized. If you control the displayed content (seems that's your case here) or you are sanitizing it upstream, then it's fine to use html
of course.
The original option property html
is documented here: https://sweetalert2.github.io/#configuration
Supported by ngx-sweetalert2 with the [html]
Input here: https://github.com/sweetalert2/ngx-sweetalert2/blob/master/src/swal.component.ts#L34
You can also use the *swalPartial
directive for more complex use cases and templates, it is documented here: https://github.com/sweetalert2/ngx-sweetalert2#swalpartialdirective
from ngx-sweetalert2.
Hi
I'm not using the ngx-sweetalert2 but rather the normal Swal (main) sweetalert2 in an Angular 9 project.
and would like to know if it's possible to achieve what this thread is about?
Basically I would like use a component in as content in the Html... something like
Swal.fire({
title: 'RATE YOUR ORDER',
html: `<bar-rating [max]="5" [theme]="'stars'"></bar-rating>`,
showCloseButton: true
});
from ngx-sweetalert2.
@toverux thanks ! I appreciate
from ngx-sweetalert2.
Related Issues (20)
- This library is not working under IIS HOT 1
- Stricts templates & Angular Language Service HOT 1
- open multiple alerts HOT 1
- Default value for *swalPortal directive input HOT 7
- error NG8001: 'swal' is not a known element: HOT 3
- Modal when appear delete overflow-y : auto to hidden severals times HOT 1
- CommonJS or AMD dependencies can cause optimization bailouts. HOT 3
- Module not found: Error: Package path ./public-api is not exported from package HOT 1
- Generic type 'ɵɵ*Declaration' requires between x and y type arguments. HOT 8
- Add support for color property on SwalComponent
- add support for angular 15
- Cannot find module @sweetalert2/ngx-sweetalert2 or its corresponding type declarations HOT 1
- for Angular 16 HOT 4
- Compilation errors after last update - Angular 15 HOT 6
- Sweet alert over dialog primeng
- Will the library be upgraded to v17 of Angular? HOT 1
- Support for Angular 17 HOT 7
- Angular 17 - Stanalone components HOT 1
- Content shrinking when popup opens HOT 2
- Error during installation in Angular 17 HOT 5
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-sweetalert2.