AngularJS - 基于json构建动态表单

时间:2014-12-23 06:30:23

标签: json angularjs

我正在使用AngularDynamicform在页面中生成动态表单,并且字段以水平方式显示正常。但我想在页面的不同部分显示输入字段。

在我的页面

<div class="box-content">
<h4 class="page-header">New Contact</h4>
<dynamic-table-form fields="fields" data="data" class="form-horizontal">

    <input dynamic-field-type="string" ng-model="value" type="text" maxlength="{{config.maxLength}}" size="{{config.maxLength}}">

    <input dynamic-field-type="date" ng-model="value" type="date">

    <ul dynamic-field-type="array">
        <li dynamic-field-child>
            <ng-transclude></ng-transclude>
            <button ng-click="removeChild(childKey)">Remove</button>
        </li>
        <button ng-click="addChild()">Add Another</button>
    </ul>

    <select dynamic-field-type="select" ng-model="value" ng-options="option.value as option.caption for option in config.options"></select>

    <input dynamic-field-type="integer" ng-model="value" type="number" size="{{config.maxLength}}" maxlength="{{config.maxLength}}" min="{{config.minValue}}" max="{{config.maxValue}}">
    <button ng-click="create()">Save</button>
</dynamic-table-form>
<button ng-click="create()">save</button>

在我的控制器中

  $scope.fields = [
             {
                 caption: 'Name',
                 model: 'name',
                 type: 'string',
                 maxLength: 25
             },
             {
                 caption: 'Date of Birth',
                 model: 'dateOfBirth',
                 type: 'date'
             },
             {
                 caption: 'Employee name',
                 model: 'employee.name',
                 type: 'string',
                 maxLength: 25
             },
             {
                 caption: 'Employee City',
                 model: 'employee.city',
                 type: 'string',
                 maxLength: 25
             }
         ];

例如,我想在其他名为Employee details的部分中显示最后两个字段(Employee name&amp; Employee City)。我该怎么办?

提前致谢。

0 个答案:

没有答案