Combining the values of two input fields in Angular

Within my form, I have three input fields labeled Name, hours, and minutes. When I execute a POST operation, I combine the values of hours and minutes into a variable named duration before sending it to the api.
The resulting JSON structure appears as follows:

[
 {
  "displayName": "Car Rent",
  "duartion": "06:27:00",
 },
 {
  "displayName": "Bike Rent",
  "duartion": "10:15:00",
 },
 {
  "displayName": "Texi Rent",
  "duartion": "05:30:00",
  },
]

However, when I concatenate the values of hours and minutes and perform a POST request, the JSON string is altered as shown below:

  [ 
   {
    "id": "7249328f-fad4-4548-87b0-947e99b57892",
     "displayName": "Car Rent",
    "duration": "1020.00:00:00",   <===============
   },
   {
    "id": "7e39f9302-77b3-4c52-a858-adb67651ce86",
     "displayName": "Taxi Rent",
    "duration": "0510.00:00:00",   <===============
   }
  ]

DEMO

Answer №1

Update the duration of the work to be equal to the hours and minutes entered in the add form.

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

A Promise signature allows for the compilation of function bodies that return undefined

The compiler error that I expected to see when using this function does not actually occur. The function body is capable of returning undefined, yet the type signature does not mention this possibility. async function chat(_: at.ChatLine): Promise<Arr ...

Issue encountered while creating production build using Ionic

I've encountered a perplexing error that has me stumped. The error reared its head while attempting to build with --prod. Despite my efforts to fix it by updating dependencies, when I run ionic cordova build android --prod --verbose, the following er ...

Tips on efficiently adding and removing elements in an array at specific positions, all the while adjusting the positions accordingly

My challenge involves an array of objects each containing a position property, as well as other properties. It looks something like this: [{position: 1, ...otherProperties}, ...otherObjects] On the frontend, these objects are displayed and sorted based on ...

Utilize forRoot to pass configuration data

When using Angular, I encountered a challenge in passing configuration data to a custom library. Within the user's application, they are required to provide config data to my library through the forRoot method: // Importing the custom library import ...

Storing data locally in Angular applications within the client-side environment

As I delve into Angular and TypeScript, I've encountered a perplexing issue. Let's say I have two classes - Employee and Department. On the server-side, I've established a Many-To-One relationship between these entities using Sequelize: db. ...

The default filterMatchType in PrimeNG DataTable Filtering is not set

I can't seem to make a data column filter work with a "contains" match type. Does anyone have any suggestions? Check out this Plunker link, and try filtering by "f70": <p-dataTable [value]="orderList"> <p-column field="itemDesc" header= ...

angular proxy configuration malfunctioning

I'm struggling to figure out where my mistake is. Despite trying the solution provided in an answer, the issue persists. Here are a few related threads I've explored: Angular-CLI proxy to backend doesn't work Configure Angular-cli proxy f ...

Dynamically apply classes in Angular using ngClass

Help needed with setting a class dynamically. Any guidance is appreciated. Below is the class in my SCSS file: .form-validation.invalid { border: 2px solid red } In my ts file, there's a variable named isEmailValid. When this variable is set to ...

ReactJS and Redux: setting input value using properties

I am utilizing a controlled text field to monitor value changes and enforce case sensitivity for the input. In order to achieve this, I need to access the value property of the component's state. The challenge arises when I try to update this field ...

Combining Axios with repeated promises

I am facing an issue with a loop in my GET request on the axis, and I cannot figure out why. const [ state, setState ] = useState<any[]>([]); ids.forEach((id) => { getData(id) .then((smth: Map<string, any>[]) => getNeededData ...

Encountering obstacles when trying to implement mongoose virtuals in a TypeScript environment

I have been exploring how to utilize virtuals in mongoose with typescript. Let's say I have an interface for defining a user. interface User { id: mongoose.ObjectId; name: string; likes: string; } Next, I define a schema for mongoose. // ...

What is the best way to move between components within the same parent class using UI router in Angular 6?

Explore the Angular UI-Router Visualizer design.component.ts import { Component, OnInit, ChangeDetectorRef, EventEmitter, Output, Input } from '@angular/core'; import { AppService } from '@app/shared/app.service'; import { Schema } fr ...

Prevent the Vue page from loading until the data has been fetched successfully

I'm in the process of finding a way to prevent my page from loading until my fetch task is completed. I'm facing some issues that need to be addressed: I have to re-fetch the data each time because I can't reuse the same data. (Changing vie ...

Issues with showing data in Angular Material tables

I recently deployed my Angular Application on a server and encountered an issue with the Angular Material table. Despite data being present in the logs, it does not display on the table. This problem only occurs in production, as everything works perfectl ...

Creating a RESTful API with Express, Firestore, Cloud Functions, and TypeScript

In my quest to create a REST API for my app, I've been delving into tutorials on Firestore & Cloud Functions. Unfortunately, all the ones I've come across are either outdated or simply don't work. This has been quite frustrating for me a ...

Manipulate Angular tabs by utilizing dropdown selection

In my latest project, I have developed a tab component that allows users to add multiple tabs. Each tab contains specific information that is displayed when the tab header is clicked. So far, this functionality is working perfectly without any issues. Now ...

Utilizing the Injector for Quality Testing Services

After bootstrapping my service before its dependency, I rely on the Injector to handle the dependency once it's ready. constructor(private readonly injector: Injector) { const interval = setInterval(() => { const myService = injector.get(MyS ...

The error at core.js:4002 is a NullInjectorError with a StaticInjectorError in AppModule when trying to inject FilterService into Table

While exploring PrimeNg Table control in my application - as a beginner in PrimeNg & Angular, I encountered an error No provider for FilterService! shown below: core.js:4002 ERROR Error: Uncaught (in promise): NullInjectorError: StaticInjectorError(AppMo ...

Validation error from Express-validator may result in TypeScript error: the request.query object could potentially be undefined

Recently, as I was developing a Node.js app using express, I decided to enhance it with express-validator. Despite being new to express-validator, the warnings it generated perplexed me due to its lack of detailed documentation. To illustrate my point, he ...

Having difficulty accessing the value of a table td element in HTML using a jQuery selector

When creating a table, I utilize ng-repeat to generate table rows. Whenever the dropdown changes, a function is triggered which applies certain conditions. Based on these conditions, an object is added to an array that is bound to a scope variable. Here i ...