์๋
ํ์ธ์, ์ ๋ ์ด์ ์ SweetAlert๋ฅผ ์ฑ๊ณต์ ์ผ๋ก ์ฌ์ฉํ์ง๋ง ์ค๋์ Ionic๊ณผ ํจ๊ป ์ฌ์ฉํด ๋ณด์๋๋ฐ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
์ด๋ ๊ฒ ์ฌ์ฉํ๋ฉด ๋ฌด์ธ๊ฐ ๊ธฐ๋ฅ์ด ์คํ๋์ง๋ง ํ์ธ ๋ฒํผ์ด ๋๋ฆด ๋๊น์ง ๊ธฐ๋ค๋ฆฌ์ง ์์ต๋๋ค.
$scope.something=function(){console.log('test')};
swal({title: 'True',text: '',type: 'success',confirmButtonText: 'Next' },$scope.something());
๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉํ๋ฉด ์ ํ ์๋ํ์ง ์์ต๋๋ค.
swal({title: 'True',text: '',type: 'success',confirmButtonText: 'Next' },function(){console.log('test')});
์ด๋ค ์์ด๋์ด?
๋๋ ๊ฐ๋์์ ๋น์ทํ ๊ฒ์ ๋ฐ๊ฒฌํ์ต๋๋ค.
$scope.deleteSomething = function () {
swal({ title: 'Are you sure?', text: 'Your will not be able to recover this thing!',
type: 'warning',
showCancelButton: true, confirmButtonColor: '#DD6B55',
confirmButtonText: 'Yes, delete it!', closeOnConfirm: false },
function () {
// Code to delete something
swal('Deleted!', 'It was deleted.', 'success');
// The success alert only shows for a split second and is gone
}
});
๋ฒ์์์ ํธ์ถ๋๋ ํจ์์ ํฌํจํ๊ฑฐ๋ ์ฝ๋ฐฑ์ ํฌํจ์ํค๋ ๊ฒ๊ณผ ๊ด๋ จ์ด ์๋ ๊ฒ ๊ฐ์ง๋ง ๋ด๊ฐ ๋ฌด์์ ์๊ณ ์์ต๋๊น? :)
๋ด๊ฐ ๊ทธ๊ฒ์ ์์ ๋ด๋ฉด ์ฌ๊ธฐ์ ๊ฒ์ ํ ๊ฒ์ ๋๋ค. https://github.com/t4t5/sweetalert/issues/52 ์์ ๋น์ทํ ์ผ์ด ๋ฒ์ด์ง๊ณ ์๋ ๊ฒ ๊ฐ์ต๋๋ค.
ํ๋ฆด ์๋ ์์ง๋ง $scope.something()์ ๊ดํธ๋ฅผ ์ฝ๋ฐฑ์ผ๋ก ์ ๊ฑฐํด์ผ ํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค.
swal({title: 'True',text: '',type: 'success',confirmButtonText: 'Next' },$scope.something);
๊ดํธ๋ฅผ ํฌํจํ๋ฉด JS ์ธํฐํ๋ฆฌํฐ๊ฐ $scope.something()์ ์คํํ๊ณ ๊ฒฐ๊ณผ๋ฅผ ์ฝ๋ฐฑ์ผ๋ก ํ ๋นํ๋ฏ๋ก ํ์ธ ๋ฒํผ์ด ๋๋ฆด ๋๊น์ง ๊ธฐ๋ค๋ฆฌ์ง ์๋ ์ด์ ๊ฐ ๋ฉ๋๋ค. ๋ ๋ฒ์งธ ์์์๋ ํจ์ ์ ์๋ฅผ (๊ดํธ ์์ด $scope.something์ ์ ๋ฌํ๋ ๊ฒ๊ณผ ๊ฐ์) ์ด๊ฒ์ด ์๋ํ๋ ์ด์ ์ ๋๋ค.
๊ฐ์ฌํ์ง๋ง ์ด๋ฏธ ์๋ํ์ง๋ง ์๋ฌด ๊ฒ๋ํ์ง ์์ต๋๋ค.
@schris12 ngSweetAlert๋ฅผ ํ์ธ ํ์ญ์์ค . ์ด์ฉ๋ฉด ๋์์ด ๋ ์ ์์ต๋๋ค
์ฝ์ ๋ก๊ทธ๊ฐ ์๋ํด์ผ ํ์ง๋ง ๋ง์ผ์ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด์์ ๋๋ค. Angular๋ฅผ ํธ์ถํ๋ ค๋ฉด $scope.$digest(); ๋ณด๊ธฐ ๋ฐ ๋ฒ์๋ฅผ ์ ๋ฐ์ดํธํ๊ธฐ ์ํด ๋ค๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ.
๋ฐ๋ผ์ ๋ฌ์ฝคํ ์๋ฆผ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ฝ๋ฐฑ์ด ๋ค์๊ณผ ๊ฐ์์ง ํ์ธํ์ธ์.
$scope.something=function(){
console.log('test');
// You might have something that updates your scope here
...
$scope.$digest();
};
swal({
title: 'True',
text: '',
type: 'success',
confirmButtonText: 'Next'
}, $scope.something);
@oitozero - ngSweetAlert๋ ๋งค๋ ฅ์ฒ๋ผ ์๋ํฉ๋๋ค! ๊ฐ์ฌ ํด์!
@oitozero , ngSweetAlert๋ ์ ๋ฅผ ์ํด ์ผํ์ต๋๋ค. ๊ฐ์ฌ ํด์!
ํ์ ์ ๊ณตํ๊ณ ๋ฌธ์ ๋ฅผ ์ดํดํ๋ ๋ฐ ๋์์ ์ค @blaiprat ์๊ฒ๋ ๊ฐ์ฌํฉ๋๋ค.
@SeanPlusPlus @ruairitobrien
์์ฒญ๋. :+1:
sweetalert(0.2.0)์ ๋ณ๊ฒฝ ์ฌํญ์ ๋ฐ์ํ๋ ์ ๋ฒ์ ์ ๋ฐฉ๊ธ ์ถ์ํ์ต๋๋ค.
๊ฐ์ฌํฉ๋๋ค.
์๊ฑฐ๋ ํฐ "ํ์ง๋ง"์ด ์์ต๋๋ค. ํ์ฑ ๋ชจ๋ธ๋ง ์ฐฝ์์ ํธ์ถํ๋ฉด ๋ฒํผ์ด ์๋ํ์ง ์์ต๋๋ค.
์ค์ปฌ์ ์์ ๋ ๋ฐฉ๋ฒ์ ์๋ ค์ฃผ์ธ์.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ฝ์ ๋ก๊ทธ๊ฐ ์๋ํด์ผ ํ์ง๋ง ๋ง์ผ์ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด์์ ๋๋ค. Angular๋ฅผ ํธ์ถํ๋ ค๋ฉด $scope.$digest(); ๋ณด๊ธฐ ๋ฐ ๋ฒ์๋ฅผ ์ ๋ฐ์ดํธํ๊ธฐ ์ํด ๋ค๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ.
๋ฐ๋ผ์ ๋ฌ์ฝคํ ์๋ฆผ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์ฝ๋ฐฑ์ด ๋ค์๊ณผ ๊ฐ์์ง ํ์ธํ์ธ์.