[英]How can I format (new lines) in bodyText of ui.bootstrap modal dialog
I have in my AngularJS-script a ui.bootstrap confirmdlg: 我的AngularJS脚本中有一个ui.bootstrap Confirmlg:
var modalDlgOptions = {
closeButtonText: "No",
actionButtonText: "Yes",
headerText: "my header text",
bodyText: "my body text"
};
confirmDlg.showModal({}, modalDlgOptions).then(function (result) {
// todo something
});
This works fine. 这很好。 But now I want to format the bodyText.
但是现在我要格式化bodyText。 I need new lines like this:
我需要这样的新行:
first line in my body text
second line in my body text
...
last line in my body text
When I use 当我使用
bodyText: "first line in my body text<br>second line in my body text<br>...<br>last line in my body text";
or 要么
bodyText: "first line in my body text<br>second line in my body text<br>...<br>last line in my body text";
I get 我懂了
first line in my body text<br>second line in my body text<br>...<br>last line in my body text
in output of my dialog, but not new lines . 在对话框的输出中,而不是在新行中 。
Is it possible to format the bodyText of the confirmDlg and how? 是否可以格式化confirmDlg的bodyText以及如何格式化?
Thank you for your hints, Thomas 谢谢您的提示,托马斯
I found this solution: 我找到了这个解决方案:
var modalDlgOptions = {
closeButtonText: "No",
actionButtonText: "Yes",
headerText: "my header text",
bodyText: ""
};
confirmDlg.showModal({}, modalDlgOptions).then(function (result) {
// todo something
});
setTimeout(function() {
var modalBody = document.getElementsByClassName("modal-body");
modalBody[0].innerHTML = "first line in my body text<br />second line in my body text<br /> ... <br />last line in my body text";
}, 100);
Thanks for the comments, Thomas 感谢您的评论,托马斯
Improving the previous solution: 改进以前的解决方案:
var waitForElementByClassName = function(element, timeout, callBack) {
window.setTimeout(function(){
if (document.getElementsByClassName(element)[0]){
callBack(document.getElementsByClassName(element)[0]);
} else {
waitForElementByClassName(element, timeout, callBack);
}
}, timeout);
};
waitForElementByClassName("modal-body", 50, function(element) {
element.innerHTML = "first line in my body text<br />second line in my body text<br /> ... <br />last line in my body text";
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.