Problem with sharing data between two controllers

56 views
Skip to first unread message

Michał Popielnicki

unread,
Jan 25, 2014, 10:00:44 AM1/25/14
to ang...@googlegroups.com
Hello Angular Community,

I've just started learning Angular and I've stumbled upon a obstacle that I can't wrap my head around. Please have a look at my very basic example here:


I have a two text inputs that should share data between MenuCtrl and FooterCtrl via SharedData service. When the app loads both fields get populated with the default value of SharedData.query then when I change value in one or the other input it does not get updated inside the other controller.

I would appreciate any clue regarding what am I doing wrong. Thank you very much.

My best

Marcin Wosinek

unread,
Jan 25, 2014, 2:45:42 PM1/25/14
to ang...@googlegroups.com
You've created in both controllers copies of a simple type - the trick boils down to have in both places references to the very same object. Like here:


2014/1/25 Michał Popielnicki <mic...@netkata.com>

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Michał Popielnicki

unread,
Jan 26, 2014, 6:16:07 AM1/26/14
to ang...@googlegroups.com
Thank you very much Marcin,

If I'll get a chance too meet you - the beer is on me :)

Best regards

--
Michał Popielnicki
Netkata :: 360 interactive media agency ::
Warecka 11/22, 00-034 Warszawa
http://netkata.com
GSM: +48 693 32 52 08, +44 20 8133 0488
Skype: mike.popielnicki


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/lchbKFTpuO4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages