I've been playing with AngularJS lately when developing a new application using a Phonegap framework.
Phonegap is a framework which lets you create mobile apps for many platforms by just using HTML5 CSS and Javascript. These won't be as fast as native apps, but it makes developing faster.. I don't want to talk about Phonegap advantages and disadvantages here.
In my mobile applicatin I use alerts and confirmations windows many times.
Ripple - chrome extension that lets you emulate Phonegap someway doesn't provide confirmation windows (as far as I know) so I had to write my own fallback code for using native phonegap notifications on phone and html based notifications. For the second, I've used a great project angular-ui bootstrap which has a dialogs built in.
The code is a AngularJS service. I won't write here how AngularJS is great and awesome. Just look at the website and find yourself using this great framework. I think that Angular service is the right place to put this into work.
I should also mention that I am using a great angular-phonegap-notification.
My intention was to make my service work similar to Phonegap notification API.