@@ -4,8 +4,11 @@ angular.module('toastr', [])
44 return {
55 replace : true ,
66 template : '<div class="{{toastClass}} {{toastType}}" ng-click="close()">' +
7- '<div ng-if="title" class="{{titleClass}}">{{title}}</div>' +
8- '<div class="{{messageClass}}">{{message}}</div>' +
7+ '<div ng-if="title" class="{{titleClass}}" ng-click="fn()">{{title}}</div>' +
8+ '<div ng-switch on="messageType">' +
9+ '<div ng-switch-when="trusted" class="{{messageClass}}" ng-bind-html="message"></div>' +
10+ '<div ng-switch-default class="{{messageClass}}">{{message}}</div>' +
11+ '</div>' +
912 '</div>' ,
1013 link : function ( scope , element , attrs ) {
1114 var timeout ;
@@ -45,6 +48,7 @@ angular.module('toastr', [])
4548 } ] )
4649
4750 . constant ( 'toastrConfig' , {
51+ allowHtml : false ,
4852 containerId : 'toast-container' ,
4953 extendedTimeOut : 1000 ,
5054 iconClasses : {
@@ -60,7 +64,7 @@ angular.module('toastr', [])
6064 toastClass : 'toast'
6165 } )
6266
63- . factory ( 'toastr' , [ '$animate' , '$compile' , '$document' , '$rootScope' , 'toastrConfig' , '$q' , function ( $animate , $compile , $document , $rootScope , toastrConfig , $q ) {
67+ . factory ( 'toastr' , [ '$animate' , '$compile' , '$document' , '$rootScope' , '$sce' , ' toastrConfig', '$q' , function ( $animate , $compile , $document , $rootScope , $sce , toastrConfig , $q ) {
6468 var container , index = 0 , toasts = [ ] ;
6569 var containerDefer = $q . defer ( ) ;
6670
@@ -172,7 +176,13 @@ angular.module('toastr', [])
172176 toast . scope . title = map . title ;
173177 }
174178
175- toast . scope . message = map . message ;
179+ if ( options . allowHtml ) {
180+ toast . scope . messageType = 'trusted' ;
181+ toast . scope . message = $sce . trustAsHtml ( map . message ) ;
182+ } else {
183+ toast . scope . message = map . message ;
184+ }
185+
176186 toast . scope . toastType = toast . iconClass ;
177187 toast . scope . toastId = toast . toastId ;
178188
0 commit comments