JavaScript Angular FormArray contents order

Hya,

I have the below setup:

App.Component.Ts contents

carForm: FormGroup;

constructor(
    private fb: FormBuilder
  ) { 
    this.carForm= this.fb.group({
      name: '',
      type: '',
      extras: this.fb.array([])
    });
  }

get carExtras(): FormArray {
    return this.carForm.get('extras') as FormArray;
  }

addNewExtra() {
   this.carExtras.push(this.fb.group(new Extra());
}

Extra Model

export class Extra {
name: string = '';
description: string = '';
}

Now lets say i add 4 new Extras, the array would look as follows:

1. name = "Phantom Wheels", description = "Big dark wheels coz driver is overcompensating"
2. name = "Clearshield", description = "Simple tint that we overcharge customers"
3. name = "Rainbow Paint Job", description = "Leftover random paints mixed and thrown onto car"
4. name = "Slick Rims", description = "Major overcompensation"

I want to be able to programmatically change the order of the 4 items listed. Say i click up button next to "Slick Rims", it will swap positions with "Rainbow Paint Job" item. If i press it again it will swap positions with "Clearshield" with result as follows.

1. name = "Phantom Wheels", description = "Big dark wheels coz driver is overcompensating"
2. name = "Slick Rims", description = "Major overcompensation"
3. name = "Clearshield", description = "Simple tint that we overcharge customers"
4. name = "Rainbow Paint Job", description = "Leftover random paints mixed and thrown onto car"

Same principle if i press the down button for the entry.

Any ideas how to achieve this, its doing my head in on how to achieve this with a FormArray.

Answer:1

I'm using a generated library (LoopBack's Angular SDK) for my model's CRUD operations, and finding it difficult to unit test controllers and services that make use of them. Here's an example where I'...

I'm using a generated library (LoopBack's Angular SDK) for my model's CRUD operations, and finding it difficult to unit test controllers and services that make use of them. Here's an example where I'...

  1. unit test promise
  2. unit test promise reject
  3. unit test promise.all
  4. unit test promise resolve
  5. unit test promise angular
  6. unit test promise angular 2
  7. unit test promise jest
  8. unit test promise mocha
  9. unit test promise jasmine
  10. unit test promise chain
  11. unit test promise catch
  12. unit test promise then
  13. unit test promise javascript
  14. unit test promise node.js
  15. unit test promise java
  16. unit test promise sinon
  17. node js unit test promises
  18. unit test promise example
  19. unit test promise method
  20. angular unit test promise then

Does anyone know how to handle the connected, disconnected, reconnecting and etc on Laravel Echo? I'm using VueJS btw

Does anyone know how to handle the connected, disconnected, reconnecting and etc on Laravel Echo? I'm using VueJS btw

I've seen variation of this question on Stackoverflow that do not answer the question. The problem is that the background image is placed using % or center, left, top, etc. But what we actually want ...

I've seen variation of this question on Stackoverflow that do not answer the question. The problem is that the background image is placed using % or center, left, top, etc. But what we actually want ...

I am trying to convert an array into a javscript object that is designed to work with input checkboxes in AngularJS. This is the input array that I get from my backend: let selectedRolesDB = ['ADMIN'...

I am trying to convert an array into a javscript object that is designed to work with input checkboxes in AngularJS. This is the input array that I get from my backend: let selectedRolesDB = ['ADMIN'...