Trying to Update an list inside a forum using arrayForm

I’m trying to update my playlist form that contains normal input and an arrayform that contains a list of songs.
when I try to change the two input it works but when I try to change anything in the array all the songs inside the playlist get deleted

before updating the array list:

enter image description here

after I press on edit here’s what I get:

enter image description here

and when I try changing anything in the ArrayList I get this

enter image description here

and when I try to edit it once more I get this
enter image description here
and an error :

ERROR TypeError: Cannot read property ‘map’ of undefined

I will leave bellow all the function I used :
this in my main component:
editPlaylist(playlist: Playlist, index: number) {
const dialogRef =, {
width: ‘900px’,
data: {

        operation: 'edit',
        playlistData: playlist,
        position: index

    dialogRef.afterClosed().subscribe(result => {
      if (result) {
         this.playlists[index] = playlist;
        this.playlists[index].name =;
        this.playlists[index].description = result.description;

        this.playlists[index].songs =;


and this in my dialog componenets
ngOnInit(): void {

   this.form = new FormGroup(
        name:new FormControl('', Validators.required),
        description:new FormControl('',Validators.required),
        title:new FormControl('',Validators.required),
        artist:new FormControl('',Validators.required),
        duration:new FormControl(0,[Validators.required , Validators.min(0)]),
        songs:  this.formBuilder.array([ this.createSong() ])

    if ( === 'edit') {
      this.form ={
        name: [, Validators.required],
        description: [, Validators.required],
        songs: this.formBuilder.array(
            title: [song.title, Validators.required],
            artist: [song.artist, Validators.required],
            duration: [song.duration, Validators.compose([Validators.required, Validators.min(0)])],


please if someone is familiar with arrayform help me

Go to Source
Author: Nisrine Hafi