Skip to content

Instantly share code, notes, and snippets.

@adasq
Created April 29, 2014 21:00
Show Gist options
  • Save adasq/885b0a97cf26f898959e to your computer and use it in GitHub Desktop.
Save adasq/885b0a97cf26f898959e to your computer and use it in GitHub Desktop.
ANGULAR JS ALERT
var AlertManager = function(){
var template = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>';
this.setText = function(type, text){
$scope.alert = {text: $sce.trustAsHtml(template+text), type: (type || 'danger')};
};
this.setDangerAlert = function(text){
this.setText('danger',text);
};
this.setSuccessAlert = function(text){
this.setText('success',text);
};
this.hide = function(){
$scope.alert = null;
}
};
var alert = new AlertManager();
alert.setSuccessAlert("<a href='sss'>xdddda aq q qqqqqqqqqqqqqq dddddddddddddddddddddddddddddddddddddddddddd"+
"ssssssssssssssssssssssssss ssssssssssssssssssssssss aaaaaaaaaaaaaaaaaaaaaaaaaaa"+
"</a>");
<div ng-show="alert" ng-bind-html="alert.text" class="alert" ng-class="{'alert-{{alert.type || 'warning'}}': true, 'alert-dismissable': true}">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment