Setting checkbox value on main page when modal closes

25 views
Skip to first unread message

Ken

unread,
Mar 12, 2015, 5:18:10 PM3/12/15
to ang...@googlegroups.com
I am trying to automatically check a checkbox on the main page when a modal closes. I am using one controller for the modal and another controller for the main page. Here's the Plunker: http://plnkr.co/edit/bCe4Rv6gYebIbDtRuuPB. Any thoughts on what I'm doing wrong? Should I be using a directive here instead, or is there another way?

Tandon, Rishi

unread,
Mar 12, 2015, 8:23:23 PM3/12/15
to ang...@googlegroups.com
Hey Ken,
It seems that "agreementForm.value1" is scoped to AgreementFormCtrl only and not ContactFormCtrl.
You probably can create a PubSub communication between the controller and on clicking the "I agree" button/ agreementForm.agree method, you can broadcast an event/ notification. Then on  ContactFormCtrl, you can listen the event using $on and then bind the value to the checkbox.
For more info, kindly read through:

On Thu, Mar 12, 2015 at 5:18 PM, Ken <kendavi...@gmail.com> wrote:
I am trying to automatically check a checkbox on the main page when a modal closes. I am using one controller for the modal and another controller for the main page. Here's the Plunker: http://plnkr.co/edit/bCe4Rv6gYebIbDtRuuPB. Any thoughts on what I'm doing wrong? Should I be using a directive here instead, or is there another way?

--
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/d/optout.




Sander Elias

unread,
Mar 12, 2015, 10:51:03 PM3/12/15
to ang...@googlegroups.com
Hi Ken,

May I ask why you want to use a ui-state for this? Is this really something you need to 'navigate' to?
I created an alternate for you. Both the code and the template became a lot simpler.

Some observations I made on your plunk. If you use UI Bootstrap you don't want to include the JS files from bootstrap, they will only interfere with it.
If you use UI Bootstrap, for most things you also don't need jquery. Don't include things you don't need, as it will only add load and sluggishness to your page!
 
Does this help you enough?
Regards
Sander

Ken Davidson

unread,
Mar 12, 2015, 11:28:11 PM3/12/15
to ang...@googlegroups.com
Hi Sander, 

Thank you, your alternate is perfect. I was only using ui-state because I thought it was necessary when using the ui router. As is clear from my clumsy code, I'm new to this, and still learning.

Best regards,

Ken

--
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/aKpABr31faY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.

Sander Elias

unread,
Mar 12, 2015, 11:37:25 PM3/12/15
to ang...@googlegroups.com
Hi Ken,

Thank you, your alternate is perfect. I was only using ui-state because I thought it was necessary when using the ui router. As is clear from my clumsy code, I'm new to this, and still learning.
I suspected that. Do yourself a favor, and before delving in more, read trough John Papa's styleguide. Even if you don't (yet) understand everything he is talking about, read the whole thing. Preferably a couple of times.

Regards
Sander
Reply all
Reply to author
Forward
0 new messages