Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从表单生成UI网格表?_Javascript_Angularjs_Forms_Twitter Bootstrap_Angular Ui Grid - Fatal编程技术网

Javascript 如何从表单生成UI网格表?

Javascript 如何从表单生成UI网格表?,javascript,angularjs,forms,twitter-bootstrap,angular-ui-grid,Javascript,Angularjs,Forms,Twitter Bootstrap,Angular Ui Grid,这里的目标是获取位于引导模式中的以下表单数据,并基于表单元素(#列、行、标题等)生成UI网格表: 控制器 angular.module('myApp') .controller("modalToTable", function ($scope, $uibModal, $log) { $scope.items = ['item1', 'item2', 'item3']; //open a modal window to create a data table

这里的目标是获取位于引导模式中的以下表单数据,并基于表单元素(#列、行、标题等)生成UI网格表:

控制器

angular.module('myApp')
    .controller("modalToTable", function ($scope, $uibModal, $log) {

    $scope.items = ['item1', 'item2', 'item3'];

    //open a modal window to create a data table
    this.openModal = function (size, parentSelector) {
        var parentElem = parentSelector ? angular.element($document[0].querySelector('.modal-demo ' + parentSelector)) : undefined;
        var modalInstance = $uibModal.open({
            animation: $scope.animationsEnabled,
            ariaLabelledBy: 'modal-title',
            ariaDescribedBy: 'modal-body',
            backdrop: 'static', 
            templateUrl: 'modalToTable.html',
            controller: 'createDataTableCtrl',
            windowClass: 'modal-scale',
            //size: size,
            appendTo: parentElem,
            resolve: {
                items: function () {
                  return $scope.items;
                }
        }
    });

    modalInstance.result.then(function (selectedItem) {
        $scope.selected = selectedItem;
        }, function () {
        $log.info('Modal dismissed at: ' + new Date());
        });

    };
})

.controller('createDataTableCtrl', function ($scope, $uibModalInstance, items) {

  $scope.items = items;
  $scope.selected = {
    item: $scope.items[0]
  };

  $scope.ok = function () {
    $uibModalInstance.close($ctrl.selected.item);
  };

  $scope.closeModal = function () {
    $uibModalInstance.dismiss('cancel');
  };

});
myTable.html(目前只有一个打开模式的按钮,这是表格应该生成的地方)

添加数据表
modalToTable.html(模态)


&时代;
创建数据表
表名:
柱:
排:
创造
取消
//这就是我想从模态表单中捕获数据的地方
问题 是否有一种角度的方法来根据模式中表单的数据生成ui网格表

例如,如果我进入模式:

  • 表名:“foo表”
  • 栏目:4
  • 世界其他地区:3
我应该看到一个名为“foo table”的ui网格表,有4列3行

I just create a code sample. replace it with your code you will get you want

&时代;
创建数据表
表名:
柱:
排:
创造
取消

嗨!除了bootstrap大小属性,我看不出有什么变化?我只是使用uib网格,就像屏幕快照一样。不,我不认为你理解这个问题。我需要采用表单输入并使用它生成ui网格。因此,当用户点击“创建”按钮时,将根据formohh中的某些参数显示UI网格!然后是我的误解(没问题,如果你能对这个问题投赞成票,我将不胜感激!
<div class="modal-header">
    <button type="button" class="close" ng-click= "closeModal()">&times;</button>
    <h3 class="modal-title" id="modal-title"><strong>Create Data Table</strong></h3>
</div>

<div class="modal-body">
    <form action="" method="post" name="registration" class="register">
        <fieldset>
            <div class="form-group">
                <label for="Student">Table Name:</label>
                <input id="table-name-input" name="table-name"/>
            </div>
            <div class="form-group">
                <label for="Columns">Columns:</label>
                <input type="text" class="column-row-tableConfig" value="0" />
            </div>
            <div class="form-group" style="padding-bottom: 10px">
                <label for="Rows">Rows:</label>
                <input type="text" class="column-row-tableConfig" value="0" />
            </div>
        </fieldset>
    </form>
</div>
<div class="modal-footer">
   <button type="button" class="btn btn-primary">Create</button>
   <button type="button" class="btn btn-primary" ng-click="closeModal()">Cancel</button>
</div>

//this would be where I'd like to capture the data from the Modal form
I just create a code sample. replace it with your code you will get you want