Skip to content

A very simple Angular confirmation service using AngularStrap.

Notifications You must be signed in to change notification settings

iudelsmann/SimpleConfirm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

SimpleConfirm

A very simple Angular confirmation service using AngularStrap.

##Installing Import the js file in your html with the proper path:

<script src="<path>/simple-confirm.js" ></script >

Inject 'simpleConfirm' in your app:

angular.module('myApp', ['mgcrea.ngStrap', 'simpleConfirm']);

##Using Inject '$confirm' in any controller.

Call the service inside any function:

$confirm.show({
    content: 'Are you sure you want to do that?'
}).then(function(res){
    if(res == "yes"){
        $scope.doIt();
    }
});

The function inside the "then" will be called after both confirm and cancel ("yes" or "no"), use if to verify the selected option.

The object argument for the "show" function will override defaults, thus allowing specific texts. Available texts and their defaults are:

  • title: 'Confirm',
  • content: 'Are you sure?',
  • cancel: 'Cancel',
  • confirm: 'Confirm'

To override all defaults use (with any of the available texts):

app.run(function($confirmDefaults){
    $confirmDefaults.defaultLabels.cancel = 'Stop';
});

About

A very simple Angular confirmation service using AngularStrap.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published