Tips for dynamically adding fields to a Bootstrap model using Angular framework

I am new to webDevelopment. I have a list of buttons, but the data-target is the same model for every button click. The structure of my model is as follows -

<div class="modal fade" id="myModalHorizontal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <!-- Modal Header -->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                   <span aria-hidden="true">&times;</span>
                   <span class="sr-only">Close</span>
            </button>
                <h4 class="modal-title" id="myModalLabel">
                   Missing {{suggestivalue}}
                </h4>
            </div>

            <!-- Modal Body -->
            <div class="modal-body">

                <form class="form-horizontal" role="form">
                    (...)
                </form>
            </div>
            <!-- Modal Footer -->
            <div class="modal-footer">
                (...)
            </div>
        </div>
    </div>
</div>

The buttons are displayed as follows -

 <ul class="col-md-12 list-group suggestion">
                (…)
            </ul>

Each button opens the same model, but it should be specific to the clicked value. For example, if the button is "FullName", I should be able to add two input boxes "firstName" and "lastName". How can I dynamically add fields based on the clicked button? Any assistance would be appreciated.

Answer №1

If you want to show different fields in a modal depending on whether it's for login or registration, you can use ng-if

First, create all the fields in the modal such as firstname, lastname, email, password, and remember me

Then, when you click on the button, set a variable like showFields For example: showFields == "login" or "" showFields == "register"

To display fields that are only needed on the register page, use ng-if='showFields == "register"'

I hope this explanation helps!

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

How can I show an image on an HTML5 canvas?

Can someone please assist me in retrieving an image location stored as a string in a JSON file and displaying it on an HTML5 canvas using JavaScript? I am struggling with this task and not sure how to extract the image path from the JSON file. {"image1":" ...

Understanding the "this" keyword in React.js is crucial for

Looking for a solution: updateSongIndex: function(index) { this.setState({currentSongIndex: index }); } I want to trigger the updateSongIndex function by clicking on a div element and passing an index as an argument var trackList = d ...

Tips for deleting part of the URL at the end of all hyperlinks on a webpage

I have a large number of links on the same page that I would like to clean up by removing everything from specific characters until the end of the URL. Currently, there are too many links like this scattered throughout my page. The string "$amp;rs" or "&a ...

Getting the id of a single object in a MatTable

I'm currently working on an angular 8 application where I've implemented angular material with MatTableDatasource. My goal is to retrieve the id from the selected object in my list: 0: {id: "e38e3a37-eda5-4010-d656-08d81c0f3353", family ...

I'm interested in implementing a cooldown feature on my button, but I'm not quite sure how to go about

Working on a React.Js website and looking to improve the Contact Me page by adding a cooldown to the button. Unfortunately, I haven't shared all the code here but feel free to reach out on Discord: uvejs#5162 for more details. import "./contactpa ...

Tips on how to automatically scroll a display flex div to the bottom

Traditionally, setting scrollTop of a div can be used to scroll it to the bottom, as shown in this example: http://jsfiddle.net/jPVAf/50/ However, if the div has the style display: flex, the technique mentioned above will not work. Here is an example demo ...

What is the best way to manage font size on an HTML webpage?

In a scenario where I specify font-size = 25px along with a specific font-family, my intention is to display a character that is exactly 25px on the HTML page. However, the rendered character's size may be slightly different, such as 27px or another v ...

cycle through several handlebars entities

Hey friends, I could really use your help right now. I'm attempting to iterate through these objects using handlebars. RowDataPacket { idUser: 1, username: 'xxxxxx', password: 'xxxxx', fullname: 'Julian Rincon'}, RowDat ...

The Angular routing system remains constant and does not alter

I'm encountering an issue with loading a component inside another component. Despite the browser route changing, my component fails to update or display properly... Here is my current setup: --homepage --coins-- --coinspreview <-- I am una ...

Retrieving data from a remote PHP server using JavaScript

I am currently working on two separate websites. Site A is coded using only HTML and JavaScript, while site B utilizes PHP. I am trying to figure out a way to access variables from site B within site A. For example: The code for site A looks something li ...

Maintain a sticky position with a set minimum distance from the bottom of the container

How can I position content in a container with some minimum distance to the bottom? Specifically, I want the blue element to stop before reaching the very bottom of the container. I could stack two containers on top of each other and only include the stic ...

Ways to conceal the image once the fixed navigation bar appears

I've been working on a website at After scrolling down the site, a fixed navigation bar appears. However, on this fixed navigation bar, I'd like to hide the logo navigation while still keeping it visible on the regular top navigation bar. https ...

The animations in three.js have come to a standstill

Currently, I am working on a real-time game using three.js and websockets. The project has been running smoothly until recently when I encountered a hurdle. While implementing animations, I noticed that the animations for the opposing client on the web pag ...

Switch the text within the div and alternate between showing different content in separate divs by utilizing jquery

Check out the jQuery code snippet below: $(document).ready(function () { $('#prvnote').hide(); $('#regclass').click(function () { $('#prvnote').toggle(400); $('#newdiv').toggle(400); }); ...

Deleting a sentence from a text document

Is there a way to remove a row from a text file without leaving empty lines? See the Example and Example2. Consider this scenario: Hello Hello2 String After deletion, the file should look like this: Hello Hello2 I attempted the following code but it re ...

The Highcharts download feature is not available when the title is removed

After setting the title of my chart to null, I noticed that I am no longer able to access the download menu on the chart. Check out this example for reference: http://jsfiddle.net/JVNjs/954/ var chart = new Highcharts.Chart({ chart: { renderT ...

The method models.User.fromURI is unsuccessful

When I try to call models.User.fromURI as shown below: models.User.fromURI("spotify:user:" + user, function (user) { $(div).html("<b ><a style=\"color:#FFFFFF\" href=\"spotify:user:" + user.username + "\">" + us ...

How can I configure the CSRF cookie name and header in Protractor to send a POST request to a Django server in order to set up a fixture for testing an Angular

I am facing a challenge with my Protractor test as I need to send a post request to a Django server to insert a fixture. In order to make this post request, I must adjust the xsrf setting within my app: app.config(['$httpProvider', function($htt ...

Utilizing the Google Maps API to display dynamic markers in a loop, with changing attributes

I am currently facing an issue with Google markers in the Maps API. Below is the code snippet from an AJAX success function (where 'map' is a parameter containing this code): success: function(data) { var tmpmap = map; ...

JS Find the Specific Value in an Array

I am struggling with a for loop that is used to open a unique custom modal. The opening button is designated by multiple elements with the class name of .col-sm-4 Below is the code snippet: // Locate the modal var modal = document.getElementById('my ...