Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="https://cdn.jsdelivr.net/sweetalert2/6.5.6/sweetalert2.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/sweetalert2/6.5.6/sweetalert2.min.css">
<script src="https://rawgit.com/oitozero/ngSweetAlert/master/SweetAlert.js"></script>
<link rel="stylesheet" href="https://limonte.github.io/sweetalert2/assets/example.css">
<script src="https://code.angularjs.org/1.4.3/angular.js"></script>
<div ng-controller="MyCtrl">
<!--The DOM updates using ng-bind and the function in .then()-->
<!--<div>Hello, <span ng-bind="name"></span>!</div>-->
<div>Note this text -> {{name}}</div>
<div>
<!--1) Click this button first, and hit OK-->
<button ng-click="changeMe()">click first</button>
<!--NOTE: the function changeMe() ran, which modified the $scope.name variable, which should
insntantly be reflected on the page, thanks to AngularJS's two-way binding-->
<!--Now click this button, and only at this point willy ou see the text actually changes-->
<button ng-click="decoy()">then here</button>
</div>
<!--Use this to reset back to original if you'd like to do more testing-->
<div><button ng-click="reset()">reset text</button><div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
myApp.controller("MyCtrl", function($scope, $timeout) {
$scope.name = 'original';
$scope.copy = angular.copy($scope.name);
$scope.changeMe = function() {
swal("Text should change now")
// runs on hitting "OK"
.then(function() {
// UNCOMMENT THIS and re-run the fiddle to show expected behavior
// $timeout(function() { $scope.displayErrorMsg = false; }, 0);
$scope.name = 'delayed.......'
})
}
// Triggers a sweet alert, so the DOM actually updates
$scope.decoy = function() {
swal("Look at the text now");
}
// resets the original text to its original state.
$scope.reset = function() {
$scope.name = $scope.copy;
}
})