0
I am trying to make an implementation with Sweetalert2 where I create some buttons within the "html" property. This is within a click function, which in turn is within a controller
.
I tried to add in a setTimeout()
and within the $
aplicar()
as code below:
setTimeout(function () {
$scope.$apply(function () {
swal({
title: "Lançamento por Código",
width: 400,
html: "" +
" <div>" +
" <input type='button' id='btn0' name='btn0' value='0' />" +
" </div>" +
showCancelButton: true,
confirmButtonColor: "#FFB200",
cancelButtonColor: "#FFB200",
colorHoverButton: "#5B2E90",
confirmButtonText: "Confirmar",
cancelButtonText: "Cancelar",
closeOnConfirm: true,
reverseButtons: true,
input: "text"
}).then(function () {
});
})
},0);
For this button I created, I try to create a click event, like the code below:
setTimeout(function () {
$scope.$apply(function () {
$("input[name='btn0']").on("click", function () {
$scope.valorLancProduto += "0";
$('.swal2-input').val($scope.valorLancProduto);
});
})
},0);
I tried to put the same in function init()
and a click function. My problem now arises, the event click
is not working, is not called. How can I resolve this?