角形构建器
麻省理工学院许可证
这是用CoffeeScript编写的Angularjs形式的建造者。
框架
- Angularjs 1.2.32
- jQuery 3.3.1
- Bootstrap 3
- 角刺激器
$建造者
# just $builder
angular . module ' yourApp ' , [ ' builder ' ]
# include $builder and default components
angular . module ' yourApp ' , [ ' builder ' , ' builder.components ' ]成分
###
All components.
###
$builder . components =
componentName{string} : component{object}组
###
All groups of components.
###
$builder . groups = [componentGroup{string}]寄存器组件
">
# .config $builderProvider . registerComponent = ( name , component = {}) -> ### Register the component for form-builder. @param name: The component name. @param component: The component object. group: {string} The component group. label: {string} The label of the input. description: {string} The description of the input. placeholder: {string} The placeholder of the input. editable: {bool} Is the form object editable? required: {bool} Is the form object required? validation: {string} angular-validator. "/regex/" or "[rule1, rule2]". (default is '/.*/') validationOptions: {array} [{rule: angular-validator, label: 'option label'}] the options for the validation. (default is []) options: {array} The input options. arrayToText: {bool} checkbox could use this to convert input (default is no) template: {string} html template templateUrl: {string} The url of the template. popoverTemplate: {string} html template popoverTemplateUrl: {string} The url of the popover template. ### # .run $builder . registerComponent = ( name , component = {}) ->
组件.template
{{description}}
< div class =" form-group " > < label for =" {{name+index}} " class =" col-md-4 control-label " ng-class =" {'fb-required':required} " > {{label}} label > < div class =" col-md-8 " > < input type =" text " ng-model =" inputText " validator-required =" {{required}} " id =" {{name+index}} " class =" form-control " placeholder =" {{placeholder}} " /> < p class =' help-block ' > {{description}} p > div > div >
component.popovertemplate
< form > < div class =" form-group " > < label class =' control-label ' > Label label > < input type =' text ' ng-model =" label " validator =" [required] " class =' form-control ' /> div > < div class =" form-group " > < label class =' control-label ' > Description label > < input type =' text ' ng-model =" description " class =' form-control ' /> div > < div class =" form-group " > < label class =' control-label ' > Placeholder label > < input type =' text ' ng-model =" placeholder " class =' form-control ' /> div > < div class =" checkbox " > < label > < input type =' checkbox ' ng-model =" required " /> Required label > div > < div class =" form-group " ng-if =" validationOptions.length > 0 " > < label class =' control-label ' > Validation label > < select ng-model =" $parent.validation " class =' form-control ' ng-options =" option.rule as option.label for option in validationOptions " > select > div > < hr /> < div class =' form-group ' > < input type =' submit ' ng-click =" popover.save($event) " class =' btn btn-primary ' value =' Save ' /> < input type =' button ' ng-click =" popover.cancel($event) " class =' btn btn-default ' value =' Cancel ' /> < input type =' button ' ng-click =" popover.remove($event) " class =' btn btn-danger ' value =' Delete ' /> div > form >