我在我的web应用程序(Play Framework 2.2.1 & Scala)中显示了使用ajax和AngularJS显示的客户列表。它工作正常,现在我想在我的列表中动态添加一个新客户,并使用jQuery弹出窗口(使用jQuery UI)。如何使用AngularJS表单发送POST数据以播放框架控制器
我首先搜索如何在浏览器上显示HTML/AngularJS表单发送的数据,但是当我点击我的提交按钮时,什么都没有发生......我不知道为什么,其他AngularJS操作起作用。
这里是我的代码:
的JavaScript
function AddCustomerController($scope) { $scope.add = function() { $scope.customers.push({id: $scope.email, phone: $scope.phone, isActivated: $scope.activation, name: $scope.name, roleType: $scope.roleType}); } }
HTML
<div id="dialogAddCustomer" title="title" ng-controller="AddCustomerController"> <label id="dialNewCustomerName">Add Customer</label> <label class="lblPopUp">Email</label> <input type="text" id="dialNewCustomerEmail" class="form-control" ng-model="email" /> <label class="lblPopUp">Phone Number</label> <input type="text" id="dialNewCustomerPhone" class="form-control" ng-model="phone" /> <label class="lblPopUp">Customer Activated ?</label> <br /> <input type="radio" name="activation" id="dialNewCustomerYes" value="1" ng-model="activation" /> Yes <input type="radio" name="activation" id="dialNewCustomerNo" value="2" ng-model="activation" /> No <label class="lblPopUp">Name</label> <input type="text" id="dialNewCustomerName" class="form-control" ng-model="name" /> <label class="lblPopUp">Role Type</label> <br /> <select class="form-control" ng-controller="RoleTypesController"> <option ng-repeat="roleType in roleTypes" value="{{roleType.id}}" ng-model="roleType">{{roleType.name}}</option> </select> <br /> <button class="btn btn-default" type="submit" ng-click="add()">Validate</button> </div>
其次,我不知道如何将数据推到我的控制器(我已经在网上搜索)corr在数据库中插入新客户。
任何想法或提示?
哎呀,我忘了改变我的控制器,我试图测试一些东西..我会编辑这个。无论如何,我已经试图把客户对象,但它似乎没有改变。 – Azuken