A
A
Andrew2016-04-07 13:03:24
JavaScript
Andrew, 2016-04-07 13:03:24

Angular - how to change the value of the model in another when changing the value of the model in one controller?

I just can’t understand how to make it so that when you enter in one field, the value in the other immediately changes, and the fields are in different controllers?
Here is an example of two empty controllers, two fields in each are made in order to check that Angular is working as it should) https://jsfiddle.net/vyzs7447/
Here's how to add a service to this code, or how to call methods from one controller or get accessing another's scope so that the other is aware of the change in scope?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2016-04-07
@byte916

In general, I answer to myself, the issue is resolved. Example - https://jsfiddle.net/vyzs7447/3/

P
Pavel Shvedov, 2016-04-07
@mmmaaak

xs is there any pattern specifically for angular, and so, in the forehead, you can organize events and subscribe controllers to them. An angular service is suitable as an event manager, for example. Surely there are ready-made implementations, google for "angular pubsub service"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question