Giter Club home page Giter Club logo

ng-form-generator-bower's Introduction

ng-form-generator

npm version Bower version

A drag and drop form generator

ng-form-generator is the perfect solution for developers looking to create a form builder for their websites

Development repo

Installation

In order for ng-form-generator to work it requires angular, bootstrap and ui-bootstrap

After you've made sure those 3 exist in your project, install with npm:

$ npm install ng-form-generator

then include it in your project

    <script src="node_modules/ng-form-generator/ng-form-generator.min.js"></script>
    <link rel="stylesheet" href="node_modules/ng-form-generator/ng-form-generator.min.css">

or use bower:

$ bower install ng-form-generator
    <script src="bower_components/ng-form-generator/ng-form-generator.min.js"></script>
    <link rel="stylesheet" href="bower_components/ng-form-generator/ng-form-generator.min.css">

Usage

Unlike other form builders out there, ng-form-generator is actually very simple to use and very light weight.

Include the formBuild as a dependency:

    angular.module('your_module', ['formBuild'])

Use the ng-form-builder directive wherever you need to place the builder

    <ng-form-builder output="output"></ng-form-builder>

The directive takes output as a parameter, which is used to store the model of the currently formed form. Store this to your backend to retrieve the form later.

Reading the form you've created requires the use of ng-form-reader.

    <ng-form-reader input="input" data="data"></ng-form-reader>

The directive takes as input, a model object that was created by the ng-form-builder directive and it outputs the actual form values with details to data.

Creating your own form item

Creating your own form item is also easy as pie.

Inject builder service into your controller

angular.module("your_module").controller("your_controller", function($scope, builder)

Then using the builder function insert, insert an object with the following data:

var customTab = {
        type: 'radio3',
        display: '<div class=""><div class="form-group"><label for="" class="col-sm-4 control-label">title</label><div class="col-sm-8"><input type="text" disabled="disabled" class="form-control" placeholder="placeholder"><p class="help-block">description</p></div></div></div>',
        popoverTemplateUrl: 'popover/sample.html',
        htmlTemplate: 'htmlTemplates/sample.html',
    };
    builder.insert(customTab);

Where:

  • type is a unique name for this type of tab
  • display is the stringified HTML that is used to display the tab in the choices list
  • popoverTemplateUrl is the url to the popover template that appears when clicked on your custom tab
  • htmlTemplate is the url to the html file of your custom tab

Creating a popover template

When creating your popover template, bind everything to $scope.object

Example:

<div class="form-group">
  <label>Popup Title:</label>
  <input type="text" ng-model="object.title" class="form-control" />
  <label>Required Field:</label>
  <input type="checkbox" ng-model="object.required" />
  <input type="text" ng-model="object.description" />
  <delete />
</div>

To add a delete button to your popover template like the one in the demo, just add <delete /> to your popover template

Creating an HTML template

When creating your html template, bind everything to $scope.object

Note that this is the same $scope.object you're binding to data to in the popover template Example:

<div class="">
    <div class="form-group">
        <label for="" class="col-sm-4 control-label">{{object.title}}
            <span ng-show="object.required">*</span>
        </label>
        <div class="col-sm-8"><input type="text" class="form-control" ng-model="object.models" placeholder="placeholder" required="object.required">
            <p class="help-block">{{object.description}}</p>
        </div>
    </div>
</div>

ng-form-generator-bower's People

Contributors

sayegh7 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.