Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add linebreak to textContent in $mdDialog

Tags:

angularjs

I want to add line break in .textcontent of mdDiaglog. Following is my code:

var confirm = $mdDialog.confirm()
        .title('Refresh')
        .textContent('Some information will be lost.'+'<br>'+ 'Do you want to refresh?')
        .targetEvent(ev)
        .ok('YES')
        .cancel('NO');
  $mdDialog.show(confirm).then(function () {
          $window.location.reload();
  });
}
like image 660
user3770459 Avatar asked Apr 21 '16 14:04

user3770459


2 Answers

write css class in your styles and use '\n' instead of <br> in textContent()

.md-dialog-content-body p{
   white-space: pre;
 }
like image 170
Hrishi Avatar answered Sep 30 '22 18:09

Hrishi


Use .htmlContent().

$mdDialogPreset#textContent(string) - Sets the confirm message. $mdDialogPreset#htmlContent(string) - Sets the confirm message as HTML. Requires ngSanitize module to be loaded. HTML is not run through Angular's compiler.

Documentation

like image 41
Clement Dungler Avatar answered Sep 30 '22 20:09

Clement Dungler