如果我删除默认的Html.BeginForm并替换为任何其他表单,则我的MVC表单不会提交回控制器。我错过了什么?
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
并替换此Angular表单
@model ReNtZBookings.Models.tblBooking
<div id="example" class="container">
<form name="form1" ng-app novalidate>
答案 0 :(得分:0)
听起来你正试图将两者结合起来,我认为这不可行。你需要做这样的事情:
<div data-ng-app="app">
<form name="form1" ng-form="submitForm()" ng-controller="yourController" novalidate>
<input type="text" ng-model="yourmodel.name" />
<button type="submit">Submit Form</button>
</form>
</div>
然后在你的angularjs控制器中,你需要添加submitForm()方法
var app = angular.module("app", []);
app.controller("yourController", ['$scope', function($scope) {
$scope.yourmodel = {};
$scope.submitForm = function() {
$http.post({
method: 'POST',
url: '/Controller/Action',
data: $scope.yourmodel,
}).success(function (data, status, headers, config) {
alert('success');
}
}
}]);