C
C
cjkfdt2017-09-14 00:03:55
JavaScript
cjkfdt, 2017-09-14 00:03:55

Why is form submission not working in Angular modal?

Good afternoon. Worth angular 1.3.4, dialog box idialog. Why does the POST method of this form in the popup not work? Although if this code is transferred outside the dialog box, then everything will work. There are no errors in the console, it feels like the form is invisible to the script. Most likely, the transfer of data to the controller does not work, I googled it, but I did not find a solution, maybe someone can help. Here is the code itself:

<span style="cursor: pointer" idialog="tpl-name">Открыть попап формы</span>
        <script type="text/ng-template" id="tpl-name">
          <span>Ваши контактные данные:</span>
          <form>
            <input type="text" placeholder="Ф.И.О." name="newName" ng-model="details.Name">
            <input type="text" placeholder="Телефон" name="newPhone" ng-model="details.Phone">
            <input type="text" placeholder="E-mail" name="newEmail" ng-model="details.Email">
            <input type="submit" ng-click="SendData(details)" value="Отправить">
          </form>
        </script>

app.controller("mainCrtl", function($scope, $document, $window, $http) {

$scope.SendData = function (Data) {  
        var GetAll = new Object();  
        GetAll.Name = Data.Name;
        GetAll.Phone = Data.Phone;
        GetAll.Email = Data.Email;
        $http({  
          url: "",  
          dataType: 'json',  
          method: 'POST',  
          data: GetAll,  
          headers: {  
            "Content-Type": "application/json"  
          }  
        }).success(function (response) {  
          console.log("success");
        })  
        .error(function (error) {  
          console.log("error");
        });  
      };

});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Ptolemy_master, 2017-09-14
@Ptolemy_master

I would venture to suggest that, most likely, this dialog is outside the scope of the controller. Are you entering the SendData function? When you right click on the button in the browser, go to Inspect, do you see this function in the scope tab? (I use Batarang for this purpose, I don't know what you have).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question