以角度模态提交表单

时间:2015-05-29 13:10:29

标签: angularjs forms angular-ui-bootstrap

我有一个位于URL /admin.brands/edit的模态,这里是它的代码:

<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@taglib tagdir="/WEB-INF/tags" prefix="tags"%>
<%@taglib uri="/WEB-INF/tlds/fields.tld" prefix="fields"%>


<div class="row-fluid sortable">
    <div class="box span12">
        <div class="box-content">
        <form class="form-horizontal" name="brandform" action='/admin.brands/update' data-toggle="validate" method="post">
            <fields:form formName="brand.id.form"> 
                <input type="hidden" name="brandid" value="{{item.brandid}}"/>
            </fields:form> 
            <fields:form formName="brand.form">  
                <div class="section-heading"></div>
                <div class="control-group">
                    <label class="control-label" for="selectError"><tags:label text="name"/> *</label>
                    <div class="controls">

                        <input name="name" value="{{item.name}}" required/>
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label" for="selectError"><tags:label text="isactive"/> </label>
                    <div class="controls">
                        <input type="checkbox" ng-checked="item.isactive" name="isactive" value="1"/>

                    </div>
                </div>
            </fields:form> 
                <div class="form-actions">
                    <a ng-click="cancel()" class="btn btn-ext-lightblue"><tags:label text="close"/></a>
                    <button type="submit" ng-click="ok()" class="btn btn-ext-darkblue btn-disable-on-submit" ><tags:label text="save"/></button>
                </div>
        </form>
    </div>
</div>
</div>

及其控制者:

    app.controller("BrandCtrl", function ($scope, $http, $modal) {
        $scope.animationsEnabled = true;
        $scope.open = function (id) {
            var modalInstance = $modal.open({
                animation: $scope.animationsEnabled,
                templateUrl: '/admin.brands/edit',
                controller:gg,
                resolve: {
                    item: function($http) {
                        return $http.get('/admin.brands/getJsonBrandAndEdit?brandid=' + id)
                            .then(function(response) {
                                return response.data;
                            });
                    }
                }
            });
        }
    });

var gg = function ($scope, $modalInstance, item) {
    $scope.item  =  item;
    $scope.ok = function () {
        $scope.form.brandform.submit();
        $modalInstance.close();
      };

      $scope.cancel = function () {

        $modalInstance.dismiss();
      };
}

我的问题是;如何将此表单提交到URL&#39; /admin.brands/updateBrand' ?

我尝试通过添加ng-model来获取表单值,但它没有用。

0 个答案:

没有答案
相关问题