为什么我用这个angularjs表单得到了一个错误形成的请求?

时间:2017-04-08 20:16:07

标签: angularjs

我有下表:

<uib-accordion>
    <uib-accordion-group heading="Roles" is-open="true">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>Role Name</th>
                <th>Access for</th>
                <th>Access to</th>
                <th>Action</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="role in ctrl.app.roles.base track by $index">
                <td>
                    <input type="text" class="form-control" id="inputRoleName" name="inputID" ng-model="role.id" placeholder="Enter mame of role" ng-minlength='3' ng-maxlength='100' required>
                </td>
                <td>
                    <input type="text" class="form-control" id="inputResource1" name="inputRes1" ng-model="role.res1" placeholder="Enter name of first resource" ng-minlength='3' ng-maxlength='100' required>
                </td>
                <td>
                    <input type="text" class="form-control" id="inputResource2" name="inputRes2" ng-model="role.res2" placeholder="Enter name of second resource" ng-minlength='3' ng-maxlength='100' required>
                </td>
                <td>
                    <input type="text" class="form-control" id="inputAction" name="inputAc" ng-model="role.action" placeholder="Enter action required" ng-minlength='3' ng-maxlength='100' required>
                </td>
            </tr>
            </tbody>
        </table>
        <button class="cbtn cbtn-plus" ng-click="ctrl.AddRole('base')">+</button>
    </uib-accordion-group>
</uib-accordion>

它基本上是一张桌子,带有&#39; +&#39;按钮位于表格的底部,每当您单击它时,将出现4个文本框以填充值。现在,我为此编写了以下控制器功能:

function AddRole(section) {
    if (!self.app.roles) self.app.roles = {};
    if (!self.app.roles[section]) self.app.roles[section] = [];
    self.app.roles[section].push({actions: []});
}

但是,当我看到正在形成JSON请求时,这会出现问题。因为,在JSON请求中,无论我在文本框中填充什么值,我都会看到:

"roles":{"base":[{"actions":[]}]}

我在哪里错了? 谢谢!

0 个答案:

没有答案