angular ng-click or javascript event click inside the html prop of sweetalert2

0

I'm trying to make an implementation with SweetAlert2 where I create some buttons inside the "html" property. This is within a click function, which in turn is within controller .

I tried to add in a setTimeout() and within $ 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 it in the function init() and a click function. My problem now appears, the click event is not working, it is not called. How can I resolve this?

    
asked by anonymous 26.09.2016 / 15:40

1 answer

0

I was able to change the call of my event click, it was as follows:

$(document).on('click', "#btn0", function () {

Thank you.

    
26.09.2016 / 16:03