Angular Builder Form
How do I make an angular builder form?
What is a angular builder form? How do you make a angular builder form? This script and codes were developed by VULE on 26 October 2022, Wednesday.
Angular Builder Form - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Angular Builder Form</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css'>
</head>
<body> <div class="row" ng-app="myapp"> <div class="col-md-6 col-md-offset-3"> <h1>Form Builder</h1> <form-builder-component /> </div>
<script type="text/ng-template" id="form-builder.html">
<div class="box-widget box"> <div class="box-header with-border"> <h3 class="box-title">All Employees</h3> <div class="box-tools pull-right"> <button ng-click="$ctrl.save()" class="btn btn-primary btn-small"> Save Form </button> </div> </div> <div class="box-body"> <div class="form-group"> <label>Form Name</label> <input type="text" ng-model="$ctrl.form.name" class="form-control" /> </div> <div class="form-group"> <div class="form-inline"> <select class="form-control" ng-model="$ctrl.form.field"> <option value="">Choose Field</option> <option value="text">Text</option> <option value="dropdown">Dropdown</option> <option value="upload">Upload File</option> </select> <button class="btn btn-primary" ng-click="$ctrl.addField()">Add Field</button> </div> </div> <div ng-repeat="item in $ctrl.list track by $index"> <form-builder-text ng-if="item.type=='text'" ng-model="$ctrl.list[$index]" index="$index" on-delete="$ctrl.deleteItem($event)" /> <form-builder-dropdown ng-if="item.type=='dropdown'" ng-model="$ctrl.list[$index]" index="$index" on-delete="$ctrl.deleteItem($event)" /> </div> </div>
</div>
</script>
<script type="text/ng-template" id="form-builder-text.html">
<div class="box box-default"> <div class="box-heading"> <h3 class="box-title">Panel title</h3> </div> <div class="box-body"> <div class="form-group"> <label for="">Label</label> <input type="text" class="form-control" ng-model="$ctrl.item.label"/> </div> </div> <div class="box-footer"> <button class="btn btn-danger" ng-click="$ctrl.delete()">Delete</button> </div>
</div>
</script>
<script type="text/ng-template" id="form-builder-dropdown.html">
<div class="box box-default"> <div class="box-heading"> <h3 class="box-title">Panel title</h3> </div> <div class="box-body"> <div class="form-group"> <label for="">Label</label> <input type="text" class="form-control" ng-model="$ctrl.item.label"/> </div> {{ $ctrl.item.options | json }} <label for="">Options</label> <div class="form-group" ng-repeat="option in $ctrl.item.options track by $index"> <div class="form-inline"> <input type="text" class="form-control" ng-model="$ctrl.item.options[$index]"/> <a class="text text-danger" style="cursor: pointer;" ng-click="$ctrl.deleteOption($index)">Del option</a> </div> </div> </div> <div class="box-footer"> <a class="text text-primary" style="cursor: pointer;" ng-click="$ctrl.addOption()">Add option</a> <button class="btn btn-danger" ng-click="$ctrl.delete()">Delete</button> </div>
</div>
</script>
</div> <script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Angular Builder Form - Script Codes JS Codes
var app = angular.module("myapp", []);
app.component("formBuilderComponent", { bindings: { onSave: '&', list: '<', form: '<' }, templateUrl: "form-builder.html", controller: function($element, $window) { var scope = this; scope.$onInit = function() { if(!scope.list) scope.list = []; if(! scope.form) scope.form = { name: "Form Name", field: null }; }; scope.save = function() { if(scope.onSave) scope.onSave({ $event: { list: scope.list, form: scope.form } }); } scope.addField = function() { switch (scope.form.field) { case "text": scope.list.push({ type: 'text', label: 'text label' }); break; case "dropdown": scope.list.push({ type: 'dropdown', label: 'dropdown label', options : [] }) break; } }; scope.deleteItem = function(event) { if($window.confirm('Confirm Delete?')) scope.list.splice(event.index, 1); } }
});
app.component("formBuilderText", { templateUrl: "form-builder-text.html", bindings: { item: "=ngModel", index: '<', onDelete: '&' }, controller: function() { var scope = this; scope.$onInit = function() { if(!scope.item) scope.item = { label: "text label", type: 'text' }; }; scope.delete = function(event) { scope.onDelete({ $event: { index: angular.copy(scope.index) } }); } }
});
app.component("formBuilderDropdown", { templateUrl: "form-builder-dropdown.html", bindings: { item: "=ngModel", index: '<', onDelete: '&' }, controller: function() { var scope = this; scope.$onInit = function() { if(!scope.item) scope.item = { label: "text label", type: 'dropdown', options: [] }; }; scope.addOption = function() { scope.item.options.push(""); } scope.deleteOption = function(index) { scope.item.options.splice(index, 1); } scope.delete = function(event) { scope.onDelete({ $event: { index: angular.copy(scope.index) } }); } }
});
Developer | VULE |
Username | tinsatthu4 |
Uploaded | October 26, 2022 |
Rating | 3 |
Size | 2,788 Kb |
Views | 24,288 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Categories Chosen | 2,625 Kb |
A Pen by VULE | 1,473 Kb |
Custom Directive Angular | 2,388 Kb |
Mau Giao Dien Pho Dong Village Banner | 22,687 Kb |
Lwc-portal-angular | 9,452 Kb |
Angular Module practice | 1,802 Kb |
HTML FORM | 1,294 Kb |
Banking Compare | 7,742 Kb |
Space-partners | 11,682 Kb |
Angular Directive Form Player | 1,610 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Flexbox Grid - equal height | DaveOrDead | 2,855 Kb |
Brian The CSS Bee | Jonitrythall | 3,922 Kb |
12 DAYS OF XMAS | Proto78 | 2,313 Kb |
Main page display | BarryKe | 4,562 Kb |
Speech bubbles | Something | 1,547 Kb |
Base-Style | Daniel_gooss | 2,614 Kb |
CSS Variables | Jdsteinbach | 4,759 Kb |
Personal Website Redesign v2.0 | DevItWithDavid | 5,168 Kb |
DevCamp 2014 - Denver Public Library | See8ch | 5,033 Kb |
A Pen by Jonas Bjork | Jonasbjork | 3,115 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!