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?

5
  • 1
    Have you done a google search before you post here? Commented Oct 24, 2016 at 18:10
  • 1
    Post your question with your code examples. Commented Oct 24, 2016 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. Commented Oct 24, 2016 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. Commented Oct 24, 2016 at 18:37
  • 1
    Possible duplicate of How to share the $scope variable of one controller with another in AngularJS? Commented Oct 24, 2016 at 20:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.