0

I'm more or less new in AngularJS. My question is simple but I'm not sure which is the best way.

Let's say I have a list of persons (name, surname, dob, ...) in a controller (array) and view (html table) to display this array of persons.

In every line of this html table there will be and edit button to edit data of a single person.

For this there will be another controller (single person obj and view - a html form.

In one way I would like to transfer data of a single person from first controller of array of persons to second controller of a single person

and vice versa - transferring edited single person data from second controller back to the first controller thus updating one record in array of persons.

I know I can do this with some service in the middle, but is there some more elegant way?

Bimal Das
  • 1,882
  • 5
  • 28
  • 53
  • 1
    Have you done a google search before you post here? – Sajeetharan Oct 24 '16 at 18:10
  • 1
    Post your question with your code examples. – Bimal Das Oct 24 '16 at 18:14
  • 2
    in *very general* terms, to match the generalness of the question, I would say this sounds like a job for a directive. – Claies Oct 24 '16 at 18:30
  • I have a few use cases like this in my project at work and what seems to work best is opening a modal with the passed person object in the resolve of the first controller into the modal controller and then on edit being completed pass back the updated object in the $uib-instance. – Ronald91 Oct 24 '16 at 18:37
  • 1
    Possible duplicate of [How to share the $scope variable of one controller with another in AngularJS?](http://stackoverflow.com/questions/22584342/how-to-share-the-scope-variable-of-one-controller-with-another-in-angularjs) – Thalaivar Oct 24 '16 at 20:33

0 Answers0