0

All -

I am new to angularjs and have some difficulty understanding how to share data between controllers that changes depending on selected value of autocomplete

Here is the link to the small app I am working on to learn angularjs. I am using jquery layout plugin for splitting the screen into two halves. West pane has autocomplete to get data from googleapis (example from angular ui bootstrap webpage). Once the user select the value from list of addresses displayed via autocomplete, I want to display the value on center pane. West pane and center pane are both defined in two different controllers. I am loss to understand on how to update center pane whenever a new value is selected in autocomplete. I have read that we need to use services, but could not get it to work

1 Answer 1

1

I used the simple tutorial here to get it working: https://www.youtube.com/watch?v=HXpHV5gWgyk

Using a factory rather than a service, and changing the bindings in the html to asyncSelected.message.

Basically you include the factory in each controller and it injects the object, which you then create in the scope of each controller.

Plunker:

http://plnkr.co/edit/UMl2k2a5mS1TP7dJsiUZ?p=preview

Sign up to request clarification or add additional context in comments.

Comments

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.