O'Reilly logo

Learning Web Development with Bootstrap and AngularJS by Stephen Radford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Utilizing AngularStrap's services

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 ng-click directive:

<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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required