How do I convert a string of numbers into a list format for displaying on an HTML table with AngularJS?

I am populating an HTML table dynamically using input from textboxes. I want to achieve the following:

Given

$scope.submittedNumbers = 00251212 00254545 00257878 00256565

Display as

00251212

00254545

00257878

00256565

Below is my AngularJS function for adding a row to the HTML table. How can I make this work?

$scope.addCertificate = function () {

    var certificate = {
        emailAddress: $scope.emailAddress,
        certificateType: $scope.certificateType,
        searchType: $scope.searchType,
        submittedNumbers: $scope.submittedNumbers,
    };

    $scope.requests.push(certificate);
};

Answer №1

To break it down into an array in the controller, simply use the following code:

$scope.splitNumbers = $scope.inputNumbers.split(' ');

Then, loop through it using ng-repeat:

<ul>
    <li ng-repeat="num in splitNumbers">{{ num }}</li>
</ul>

Finally, you can rejoin the numbers with:

var joinedNumbers = $scope.splitNumbers.join(' ');

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 to Identify and Print a Specific Property in a JSON Object using Node.js?

Hey there, I'm having trouble extracting the trackName from the JSON object provided here. I've tried accessing it using this code: console.log(res.text.results[0].trackName); but unfortunately, I keep getting this error message: TypeError: Cann ...

Label Overlapping Issue in React Select

Utilizing react-select version ^5.1.0, I am encountering an issue where the word "select" overlaps with the options when scrolling. An image has been attached for better clarification. How can I eliminate the occurrence of the select word overlapping my op ...

Close the Hopscotch modal when moving to the next step or reaching the end

I'm having trouble figuring out how to close the modal after opening it. Initially, I can open the modal successfully using the following code: onNext: function() { $('#modal').modal('toggle'); } However, when attempting to cl ...

Is it possible to modify the URL parameter of a website?

The URLs on this website all include "#" and appear untrustworthy. While I'm not well-versed in JavaScript and Ajax, it's clear that the site was not designed with SEO in mind. The company that created this site was unable to change the parameter ...

Is there a way to utilize ajax to submit a form and upload a file to a spring controller?

I have a form with four fields: file, name, type (as a string), and taskInstanceId. <form> <table id="documentDetailsTable"> <tr> <td>Document Type: </td> <td><select id="documentType" ...

What is preventing me from utilizing a property value of the parent entity in the Where method within Include?

Is there a way to query data where the created date of a child entity is the same as that of the parent entity? I attempted the following code: context.Parent.Include(p => p.Child.Where(c => c.CreatedDate == p.CreatedDate)).ToList(); However, I enco ...

The UI-Router system allows for states with varying and distinct views

My app consists of multiple pages, each with its own unique view. The states of the pages are as follows: login posts posts.post cities cities.post I have organized "posts.post" and "cities.post" as children of posts and cities respectively so that user ...

The scale line on the OpenLayers map displays the same metrics twice, even when the zoom level is different

When using the Openlayers Map scale line in Metric units, a specific zoom rate may be repeated twice during the zoom event, even though the actual zoom-in resolution varies on the map. In the provided link, you can observe that the zoom rates of 5km and ...

What is the best method for displaying over 1000 2D text labels using three.js?

Currently, I am in the process of designing a floor plan that includes over 1000 2D meshes with shapeGeometry and basicMeshMaterial on the scene. I also need to incorporate 2D text within these meshes while ensuring that the text is hidden within the bound ...

AngularJS ng-model not refreshing its data

I am currently facing an issue with my HTML code. The problem is that the model (filter) changes when I select one of the static options, but it does not trigger a change for the dynamic options. Any suggestions on how to fix this? Thank you. <div cla ...

Algorithm for combining animation with a click event in JS/jQuery

I am currently working on a webpage that displays a simple div when the cursor is not hovering over it. When the cursor hovers over the div, it fades into a different div with unique content. The intention is for the simple div to remain non-clickable, wh ...

Exploring the power of indexedDB within a PhoneGap app

I am currently working on developing an offline application using PhoneGap and I need to integrate a local database for this purpose. In my index.js file, which loads the application, I have a global variable. var db; I have a controller that saves the d ...

Implementing optimal techniques to create a JavaScript file for data retrieval in a Node.js application

I've developed a file specifically for data access purposes, where I'm keeping all my functions: const sql = require('mssql'); async function getUsers(config) { try { let pool = await sql.connect(conf ...

Ensuring that a $(function() is consistently executed and does not diminish over time

Simply put, I am troubleshooting my website and in order for it to function properly, I need to include the following code: <script type="text/javascript"> $ (function() { RESPONSIVEUI.responsiveTabs(); }); </script> What I& ...

Obtaining input value when button is clicked

I am currently working on a feature where, upon clicking the Submit button, I aim to retrieve the value entered into the input field in order to update the h1 element. import React from "react"; function App() { const [headingText, setHeadingT ...

Loading the central portion exclusively upon clicking a tag

Is there a way for websites to load only the middle section of the page when a link (a-tag) is clicked? I understand this is typically done through AJAX, but how does it update the URL to match the href in the a tag? I've tried using the .load functi ...

Preventing the cascading effects of past hovers with AngularJS

I am working with AngularJS and have the following HTML code snippet. <div class="row" style="margin-left:60px; text-align:center;"> <div class="col-xs-1 " style="margin-left:25px;width:10px; " ng-repeat="image_thumb_id in image_thumbnail_ ...

When executing npm run dev, an UnhandledPromiseRejectionWarning is triggered

I'm encountering an UnhandledPromiseRejectionWarning error when running npm run dev on my Vagrant machine, and I'm struggling to identify the root cause. The console output suggests that a promise is not being properly completed with the catch() ...

AngularJS does not refresh the DOM as anticipated

I have a fiddle demonstrating the geocoding of an address input into a textbox. The issue I'm facing is that after pressing 'enter', the table does not update immediately; it waits for another change in the textbox. How can I make it update ...

Calculating tables dynamically with jQuery

I have encountered an issue with my dynamic form/table where newly added rows are not being calculated correctly. While the static elements function as expected, the IDs and classes of the new rows do not align with the calculation logic. Can someone offe ...