It's so simple in a non-Angular environment. Just html and a two line of js code to show a modal confirmation dialog on the screen.
Now I am developting an AngularJS project in which I am using ui-bootstrap modal confirmation dialogs all over the place and I am sick of creating new controllers even for simple things like "Are you sure to delete this record?" kind of stuff.
How do you handle these simple situations? I am sure some people wrote some directives to simplify the needs.
I am asking you to share your experiences or the projects you know about that subject.
so create a reusable service for that... read here
code here:
html for display
once this is done... you just have to inject above service whereever you want to create a dialog box, example below
You can use the Angular Confirm library.
When included, it's became available as a directive:
As well as a service:
You can see my example. whatever i'v done.
script
For anything that has code that is triggered with a ng-click I just add a confirm attribute
eg
and confirm comes from (not mine, found on the web)
My google FOO has failed me and I cannot find the source site for this. I will update if I find it.
You can create a simple factory like this
In your controller
I have passed
$scope
in service function so that you can access closeModal function and in case you want to access some data from your controller . In your html