npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-form-generator

v1.2.1

Published

A lightweight and easy to use form builder

Downloads

34

Readme

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

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>