使用 angular 提交包含 POST 操作的表单

Submit a form with POST action using angular

我正在尝试使用 angular1 提交表单,但是当我单击提交时,我无法在 Chrome 开发工具的 Network 选项卡中看到对 /create 的调用。

我的app.js是:

app.controller('MyCtrl', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $http, $timeout) {
    $scope.loaderHidden = true;

    $scope.csvurls = function() {
        alert("here");
        $http({
            method : 'POST',
            url : '/create'
        })
    }
    ....
}]);

我的表格如下:

    <form class="form-inline" ng-submit="csvurls()">
      <input type="text" id="inlineFormInput">
      <button type="submit" class="btn btn-primary">Submit</button>
    </form>

当我点击提交时,我可以看到 alert 但是,我不认为正在启动对 /create 的调用。我也没有在日志中看到任何错误。

FWIW 我也在我的应用程序中使用 ng-file-upload

您需要像这样添加 $http 作为依赖项:

app.controller('MyCtrl', ['$scope', 'Upload', '$http', '$timeout', function ($scope, Upload, $http, $timeout) {