Auto-populate model objects with information automatically

I have a model...

export class myModel{
  PropertyA: string;
  PropertyB: number;
  PropertyC: string;
  PropertyD: number;
  }

The data retrieved consists of...

  this.store.select(myDataStoreName)
  .subscribe(data=> {
    
  }

This is how the returned data appears...

"0: dataArray
    PropertyC: SomeText
    PropertyD: 33"

What is the best way to automatically assign this returned data to a new object that follows the structure defined in the model?

My goal is to generate a new object after receiving the data and then update specific values based on the incoming data without manual intervention.

Answer №1

Transform your information into myModel and then link it to a fresh entity.

this.dataStorage.select(myDataStoreName)
    .observe((info: myModel[]) => {
      const updatedEntity = info[0]; // generating new entity.
     });

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

Ways to remove modules from an Angular build process?

Within my Angular application, there exists a multitude of modules. My goal is to omit certain modules from the Angular build. For example, I have a repository containing the entire codebase with various Angular modules such as chat, dashboard, products, ...

Establish a function within an interface using the name obtained from a constant in Typescript

How can I define functions within an interface using constants as function names? I have a const array containing event names and I want to create an ServerToClientEvents interface for SocketIO. I can define a function like this and it will work: interfac ...

Having trouble uploading SharePoint list item with attachment from Angular to ASP.NET Core Web API via NgModel

Recently, I successfully added a SharePoint list item with an attachment from Angular to ASP.NET Core Web API. This was achieved using FormControl in the Angular application. I found guidance on how to upload files from Angular to ASP.NET Core Web API at ...

Testing the persistence behavior of Angular's singleton service by injecting a fresh instance

My Angular Service relies on another Service for persisting data across page loads: @Service({providedIn: "root"}) class PersistenceService { save(key: string, value: string) { ... } load(key: string): string { ... } } @Service({providedIn: ...

Tips for preventing access to the login route in Angular if a user is already logged in and keeping them on the current route

My implementation of AuthGuardService effectively prevents unauthorized access to protected routes by users who are not logged in. However, I am now aiming to ensure that if a user is already logged in and attempts to access the Login Route again, they re ...

My Angular7 app.component.html file is not displaying the routing. What could be the issue?

After implementing the code in app.component.html in Angular 7 like this: <div id="wrapper"> <header id="header-container" class="fullwidth"> <div id="header"> <div class="container"> <div class="left- ...

Error message: Unable to instantiate cp in Angular 17 application while building with npm run in docker container

After creating a Dockerfile to containerize my application, I encountered an issue. When I set ng serve as the entrypoint in the Dockerfile, everything works fine. However, the problem arises when I try to execute npm run build. Below is the content of my ...

Problem with Ionic 2 checkboxes in segment controls

I encountered an issue with my screen layout. https://i.sstatic.net/bFeZN.png The problem arises when I select checkboxes from the first segment (Man Segment) and move to the second segment (Woman Segment) to choose other checkboxes. Upon returning to th ...

ngModelChange doesn't trigger if the value is manually altered

Here is the scenario I am experiencing: //html <input (ngModelChange)="onSelection()" [(ngModel)]="selectedNode" > // in the ts file onSelection() { alert('changed'); } Typing something inside the input tri ...

Display content from an external HTML page within a div using Ionic

Currently, I am facing an issue where I am utilizing [innerHtml] to populate content from an external HTML page within my Ionic app. However, instead of loading the desired HTML page, only the URL is being displayed on the screen. I do not wish to resort t ...

How can you specify the active route in Angular?

I am curious about whether it is possible to set the active route from a script instead of just from the HTML template. Let me provide an example: @Component({ template: `<input type="button" (click)="back()" value="back" ...

Determine the exact Angular TemplateRef within a QueryList

Within Angular 6/7, I am facing an issue with a component where I am projecting content such as (ParentComponent template): <my-component [templateNames]="['t1', 't2']"> <ng-template name="t1">...</ng-template> &l ...

The ngx-bootstrap tooltip arrow adapts its color to match the boundaries that it is surrounded by,

https://i.sstatic.net/Gmv9l.png I am currently utilizing ngx bootstrap tooltip in my project. My goal is to modify the color of the arrow element as demonstrated below: .tooltip.customClass .tooltip-arrow { border-right-color: white; } However, I ha ...

I am facing restrictions in TypeScript when trying to modify RX JS responses

Can someone help me with a quick solution to this Angular 4 issue? title:string; content: string; comment: string; constructor( private http: HttpClient) {} posts: {title: string, content: string, comments: String[]}[] = []; ngOnInit() { this. ...

Iterating over elements with a custom width using ngFor in Bootstrap

I'm currently using *ngFor to cycle through multiple images as the background of each column in a row using Bootstrap. One thing I'm wondering is how to control the width of each column. For example, if I have 10 images, how can I adjust the widt ...

What is the process of programmatically sorting a column in a Material UI DataGrid?

Hey there! I'm currently working on a DataGrid that has a column with a custom header, specifically a Select option. My goal is to have the column sorted in descending order every time a user selects an option from the dropdown menu. renderHeader: (pa ...

access denied on image links

While developing a web app with Angular5, I encountered an issue regarding retrieving image URLs from the 4chan API. Each post in my database contains an image URL, however, when I try to access it through my app, I receive a 403 forbidden error in the con ...

There seems to be an issue with the functionality of Angular bindings

Within a form, there is a specific control that looks like this: <select class="form-control" [(ngModel)] ="flightChoice.twoWays" id="twoWays" formControlName="TwoWays"> <option value="false" >one way</option> <option value="t ...

Is it possible to remove a complete row in Angular 2 using Material Design

JSON [ { position: 1, name: 'test', value: 1.0079, symbol: 'HHH' }, { position: 2, name: 'test2', value: 4.0026, symbol: 'BBB' }, { position: 3, name: 'test3', value: 6.941, symbol: 'BB' }, ...

NestJS service does not support DTO functionality

In my situation, I am using a DTO that looks like this: export class CreatePlotDTO { @IsNumber() @ApiProperty() @IsOptional() area: number; @IsNumber() @ApiProperty() @IsOptional() ownerID: number; } I also have a method named create. UPD ...