THE PROBLEM:
我想在甜蜜警报上单击“确定”后将用户重定向到另一个页面,但是在我出于某种原因打开另一个甜蜜警报之前,用户不会被重定向 .
您可以在代码上断点,但页面上没有任何反应 .
NOTE :包括0秒超时"solves the problem"
重现:
1)注意箭头后面的文字.. $ scope.name = "original",你可以看到它显示在页面上 .
2)单击"click first"按钮 . 这运行函数$ scope.changeMe(),它将$ scope.name更新为"delayed......."
3)到现在为止,按钮上方的文本应该已经改变 . 但是,直到你打开另一个甜蜜警报,文本才真正改变
4)单击"then here"或"click first"按钮,弹出另一个甜蜜警报,DOM将最终更改 .
我很确定这与AngularJS有某种关系,必须使用1.4.3 .
有任何想法吗?
HTML:
click first
then here
reset text
JS:
var myApp = angular.module('myApp',[]);
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.......'
})
}
$scope.decoy = function() {
swal("Look at the text now");
}
$scope.reset = function() {
$scope.name = $scope.copy;
}
})