4
我用AngularJS V1.5.3 & vendor.bundle.js和app.bundle.jsAngularjs變量值沒有更新第一次與sweetAlert是成功
在該點擊,以顯示按鈕和顯示SwaI位確認框,我按'是,顯示它!'按鈕和DIV沒有顯示,但是,我按第二次則顯示這個div,我的意思是$ scope.displayDiv值改變但第一次 沒有任何影響,請給我解決
在這裏,我貼我的代碼:
<div class="input-group" ng-show="displayDiv" >
DOM data
</div>
<button class="" ng-click="disDiv()">Show</button>
$scope.displayDiv=0;
$scope.disDiv = function() {
swal({
title: 'Are you sure?',
text: "You won't to display",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, display it!',
cancelButtonText: 'No, cancel!',
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger',
buttonsStyling: false
}).then(function() {
$scope.displayDiv=1;
});
};
請不要在angularjs相關問題上使用角標記 –
成功事件不在角度世界。用戶$ scope。$ apply – seyfside
非常感謝'seyfside',它的工作正常... –