The majority of the modules included within AngularStrap also expose services to our application. We can use these to show things such as modals, alerts, and popovers without having to use a directive.
Let's take a look at how we can use the
$alert service to show an alert from our controller. We're going to use the
ng-click directive on a button to trigger it all. First of all, create a button and attach the
<button class="btn btn-success" ng-click="showAlert()">Alert via Service</button>
We'll sort the
showAlert() function out in our controller in just a second. Before that, we need to create an alert using that service. Inject
$alert into the controller and create a new instance of an alert ...