How to build dynamic controls in angular js using json?

I am working on a angular js project. Right now the controls are static. But client wants to create the html controls based on database.

I have a table with controls specification

For eg:

type : text/dropdown/radio/checkbox

events : onchange/onblur/onfocus


How can I generate the dynamic model which can parse database value to html controls?

Any help would be really appreciated...


This is pretty easy using the ng-repeat directive. Note how I assign the value of the model back to the scope variable in the ng-repeat. This allows me to retrieve it later.

angular.module('formModule', []).
controller('DynamicFormController', ['$scope',
  function($scope) {

    //Set equal to json from database
    $scope.formControls = [{
        name: "Name",
        type: "text"
      }, {
        name: "Age",
        type: "number",
        color: "red"

        name: "UseNestedControls",
        type: "checkbox",
        nestCondition: true,
        nestedControls: [{
          name: "NestedText",
          type: "text"

<script src=""></script>

<body ng-app="formModule">
  <div ng-controller="DynamicFormController">
      <div ng-repeat="input in formControls">
        <input type="{{input.type}}" ng-model="input.value" ng-style="{'color':input.color}" />
        <div ng-repeat="nestedInput in input.nestedControls" style="margin-left:20px" ng-show="input.value == input.nestCondition">
          <input type="{{nestedInput.type}}" ng-model="nestedInput.value" ng-style="{'color':nestedInput.color}"/>
    <div ng-repeat="input in formControls">
      <span>{{}} = {{input.value}}</span>
      <div  ng-repeat="nestedInput in input.nestedControls" style="margin-left:20px">
        <span>{{}} = {{nestedInput.value}}</span>


 ? Angular 2 set dynamic functions name on element
 ? Setting the hostname based on tags from dynamic inventory
 ? Setting the hostname based on tags from dynamic inventory
 ? Setting the hostname based on tags from dynamic inventory
 ? C++ Dynamic Inventory System--Adding/Removing Items
 ? Ansible Dynamic Inventory: Auto-incrementing Integer Assignment to Hostvars
 ? How to set a variable using dynamic inventory using Ansible
 ? Mixing Ansible static and dynamic groups in inventory
 ? Filtering multiple tags in Ansible dynamic inventory
 ? How to change hostname for dynamic inventory?