Problems $Scope mdDialog Angularjs

Asked

Viewed 126 times

2

Good morning guys!

I’m having trouble passing an array to an Md-dialog.

Clicking an edit button sends the array in $Scope via locals to the Md-dialog controller, so I can change the data and save it. But the problem is that any modification I make in the array within the Md-dialog is applied simultaneously in the array of the page that is "behind" the dialog (page that sent the data), even if I cancel the dialog.

For example: I pass the multi-line array to the dialog, and if I remove a line from the array there in this dialog it also removes the line from the upload page array. It seems that they are linked and everything that happens in one is repeated in the other even if I cancel the dialogue. Dai when I go back in the edit array is without the line that was deleted before even having canceled the dialog.

Thank you from the outset for helping.

Hug!

  • You can share code regarding your problem?

1 answer

2


Yes, they are connected, it is an Angularjs Feature, it is the root of the way it works, the MVVM.

If you want to make modifications to your array within the scope of the Md-dialog and if this array needs to be the same as the parent scope, you can use the angular.copy() to create a copy of the array and pass it to the Md-dialog.

  • Perfect Juan!! I had no idea of the existence of this command. I’m starting with the angular and helped me a lot here. Thank you very much. Great hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.