Are you on the lookout for an Angular2 visual form editor or a robust form engine that allows you to effortlessly create forms using a GUI, generator, or centralized configuration

In our development team, we are currently diving into several Angular2< projects. While my colleagues are comfortable coding large forms directly with Typescript and HTML in our Angular 2< projects, I am not completely satisfied with this method.

We are about to embark on new projects that will require extensive form structures, possibly with conditional logic, and these projects are expected to expand over the next few years. I believe that writing the code directly in Typescript/HTML, even with separate components and services, will result in a significant amount of redundant code. Any changes or additions to the forms in the future would be very cumbersome.

Is there any visual form editor available for AngularJS 2 that supports complex form structures? Or perhaps a form engine that offers a GUI, generator, or centralized configuration for creating intricate form layouts?

I simply want to develop advanced form structures in Angular2< without unnecessary coding complexities.

Answer №1

Lately, I completed a project involving an angular application with a form that has over 50 fields. My recommendation is to break it down into smaller components and pass the form instance to child components. You can divide it into sections like basic information and social media, each having its own component. Any updates, such as adding or removing fields, can be handled by passing data back to the parent component using @Input and @Output() decorators, which then updates the changes locally and remotely (via HttpClient).

 form = this.fb.group({
    basic: this.fb.group({
      name: '',
      description: ''
    }),
    social_media: this.fb.array([
      this.createSocialMedia({ sm_id: 1, sm_name: 'facebook' }),
      this.createSocialMedia({ sm_id: 3, sm_name: 'instagram' }),
    ])
  })

Parent template:

<div>
      <form [formGroup]="form" (ngSubmit)="onSubmit()">
        <app-basic
          [parent]="form">
        </app-basic>
        <app-social-media
          [parent]="form"
          [media]="social_media"
          (added)="addSocialMedia($event)">
        </app-social-media>
     </form>

Child component template for basic:

<div [formGroup]="parent">
      <div formGroupName="basic">
        <input 
          type="text" 
          placeholder="Name"
          formControlName="name">
        <input 
          type="text" 
          placeholder="Description"
          formControlName="description">
      </div>
    </div>

If you want to introduce a new feature, like billing information, all you have to do is add

billing: this.fb.group({...//billing details})
to your existing form. Then, include
<app-billing></app-billing>
in the parent template and create the template for the billing section.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Removing unnecessary keys from intricate JSON data (with the use of pure JavaScript)

I've experimented with various methods to dynamically parse and remove keys with empty values from a JSON file using JavaScript. Currently, I can successfully delete non-nested keys, except for empty strings that have a length greater than 0. My mai ...

Error: The function 'check' is not defined and cannot be called when the 'on

My aim is to display the "expandrepeat" div when a specific select option is chosen. Unfortunately, the code below doesn't seem to be working as intended: <script> window.check=function(elem) { if (elem.selectedIndex == 1) { documen ...

Why does my Javascript cross-domain web request keep failing with a Status=0 error code?

UPDATE: I've been informed that this method doesn't work because craigslist doesn't have an Allow-Cross-Domain header set. Fair point. Is there an alternative way to download a page cross-domain using Javascript in Firefox? It's worth ...

Executing an AngularJS function through CasperJS is a common task that can

I am facing a challenge with testing a directive within a controller. The unit tests I am trying to write involve executing this code, which is triggered not by a click event but rather by a socket.io emit. Instead of attempting to mock socket.io, I am exp ...

Utilizing Visuals from a Vue Component Collection

As I attempt to publish a Vue library to npmjs, I encounter an issue with the images within it. After publishing the app to NPM and importing it into my main app, everything appears to be working correctly. However, the paths to the images in the library ...

`Check out Vue3's property watching feature`

Currently, I have a form that is being edited and the created method is used to prefill the form information from an api call, which works perfectly fine. However, my goal is to monitor the fields in the form. If any of them are edited, I want to set a va ...

Modify the view to display the router outlet as a sidebar

Hello, I am trying to figure out why I am unable to access a child route in my application. I have a sidebar where I want to display a list, and if I want to add or edit an item, I would like the view to change within the sidebar from the list to a form a ...

Is it possible to integrate two calendars into the `DatePicker` component of MUI?

The <DateRangePicker/> component from MUI has a prop called calendars which determines the number of calendars displayed inside the component popup. Here is an example: If the calendars prop has a value of "3", it will look like this: https://i.sta ...

Is it possible for me to customize the default angular filter in order to prioritize displaying strings that begin with the search term?

In my current project, we are dealing with a massive list of strings (17,000+ at times) and have implemented an input box for filtering the list. Initially, I used Angular's default filter, but then a request came in to sort the list so that strings s ...

I'm experiencing issues with my Ionic application Dockerize not properly functioning in the browser

I'm currently working on an Ionic study app in order to familiarize myself with Docker. I have completed all the necessary steps to create the image: 1. First, I created the Dockerfile with the following scripts: FROM node:18.10.0-alpine3.15 WORKDIR ...

invoke a managed bean to execute JavaScript code

I am facing an issue while trying to clear a hidden form value in a JSF page from a managed bean class. I tried calling a method where I used the following code snippet to call JavaScript, but unfortunately it throws a java.lang.NullPointerException. The c ...

Click to expand for answers to commonly asked questions

Having trouble setting up a FAQs page on my blog and can't seem to get the code right. Check out what I'm trying to do here: http://jsfiddle.net/qwL33/ Everything seems fine but when I click on the first question, both questions open up. Can som ...

Redirecting and styling following an HTTP post operation

Implementing Stripe on my Firebase-hosted website. Utilizing a Cloud Function to handle the transaction. I have integrated the Stripe Checkout within a button displayed directly on my single HTML page, which then directs to the /charge function in inde ...

Unable to establish a connection with the server data in pusher.js

I have been trying to set up a collaborative drawing application by following this tutorial. Although I have managed to run the application, the collaborative drawing feature is not working as expected. I have correctly configured the PUSHER_APP_ID, PUSHER ...

Issue with Submit Event in React - Enter Key Fails to Trigger

I'm currently experimenting with a small front-end react project that's using Soundcloud's API. The project is quite basic at the moment - it takes user input and queries the API for related songs. I've encountered an issue where the en ...

React Native component that enables users to both input their own text and select options from a dropdown menu as they type

Looking to develop a component that combines Text Input and FlatList to capture user input from both manual entry and a dropdown list. Has anyone successfully created a similar setup? I'm facing challenges in making it happen. Here's the scenari ...

When using JSON stringify, double quotes are automatically added around any float type data

When passing a float data from my controller to a JavaScript function using JSON, I encountered an issue with quotes appearing around the figure in the output. Here is the JS function: function fetchbal(){ $.ajax({ url: "/count/ew", dataType: "jso ...

What could be causing the Twitter Timeline to fail to load based on a variable in a Vue.js component?

My goal is to display the Twitter timeline of multiple accounts based on the route. I initially attempted to use a plugin called vue-tweet-embed, but encountered issues with it. As a result, I resorted to the traditional method by embedding twitter's ...

Create an array in JSON format that includes a JavaScript variable, with the variable's value changing each time a mouse

var question="What is your favorite color?"; var option="red"; var col=[]; When the user clicks, the variable value changes and values should be pushed in a specific format. I am new to JavaScript, please help me with this. Thank you. //On click, the var ...

Executing a JS function within a table cell

I've been attempting to invoke a function within a table cell to dynamically create some data, but I keep encountering this error below. I'm uncertain whether I'm correctly calling defined functions and JavaScript functions inside the table ...