Skip to content

A simple tool that makes it easy to build form in angular apps.

Notifications You must be signed in to change notification settings

mafengwo/LegoForm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegoForm

Build Status

Legoform is a simple tool that makes it easy to build form in angular apps. It designed to reduce the work of writing duplicated form elements in HTML and duplicated validation logic in controllers. Instead of writing duplicated elements in HTML, LegoForm uses a JSON-based Lego configuration as a form definition. ##Usage:
HTML:

<!-- Dependencies for LegoForm -->
<link rel="stylesheet" href="bootstrap.css">
<script src="angular.min.js"></script>
  
<!-- LegoForm -->
<script src="LegoForm-0.0.1.js"></script>
  
...
  
<!-- Use LegoForm -->
<lego-form lego-def="config.legoDef" ng-model="passenger"></lego-form>

Javascript:

angular.module('app', ['LegoForm'])
    .controller('PassengerController', ['$scope', '$http', function ($scope, $http) {

        $scope.config = {};
        
        $scope.passenger = {};
  
        /**
        * Fetch Lego configuration
        */
        $http.get('/api/legoDef').success(function (res) {
            $scope.config.legoDef = res;
        });
  
        /**
        * Sumbit event triggered.
        */
        $scope.$on('lf.event.submit', function (event, data) {
            // Your submit logic goes here.
        });

    }]);

About

A simple tool that makes it easy to build form in angular apps.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published