I\'m trying to use AngularJS Bootstrap alerts like explained here with the \"dismiss-on-timeout\" attribute. It has no effect in this example, the alert just appears regular
I never could get it to work. Here's a more straightforward approach:
Markup
close="closeAlert()"
alert alert-{{ alert.level }}"
ng-show="alert.show">
{{ alert.message }}
Controller
$scope.closeAlert = function() {
$scope.alert.show = false;
}
$scope.showAlertForFiveSeconds = function(){
$scope.alert.message = 'Something went wrong!');
$scope.alert.level = 'danger'; // red
$timeout(closeAlert, 5000); // close the alert in 5 seconds
}
Essentially all I'm doing is manually setting a deferred call to close the alert and walking away.
Note that doing this also requires you to inject the Angular $timeout service into the controller up top.