ngShow/ngHide detect changes

97 views
Skip to first unread message

Roland Zwaga

unread,
Feb 6, 2014, 4:19:27 AM2/6/14
to ang...@googlegroups.com
Hi there,

is there a way to detect when ngShow or ngHide gets triggered?
In my case I have a view that contains an audioplayer, I'd like to stop the audio
playing when the view gets hidden. As far as I can see no events are broadcasted
by those directives, so is there another way of detecting these changes?

Thanks in advance for any advice,

cheers,

Roland Zwaga

Mauro Servienti

unread,
Feb 6, 2014, 4:47:32 AM2/6/14
to ang...@googlegroups.com
Since they are bound to some properties in your scope why do you need to detect that?
Isn’t it enough a watch?
Can’t you broadcast yourself the change?

.m
--
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.

Roland Zwaga

unread,
Feb 6, 2014, 5:22:00 AM2/6/14
to ang...@googlegroups.com
Hi there,

yes, this was indeed a solution that I thought about as well. This would require
some custom logic on my end though (not much, I'm not complaining), so I
thought I'd ask here to see whether there's a more generic way of detecting
these changes.
But, I gather there isn't, so I'll roll my own then :)

cheers,

Roland



--
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/vpMds4nLba0/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Mauro Servienti

unread,
Feb 6, 2014, 4:42:34 PM2/6/14
to ang...@googlegroups.com
:-)

Another solution could be to write your own no-show/hide directives, they are pretty easy, in order to introduce the ability to broadcast events.
We did that for the whole validation infrastructure in order to broadcast events and also being able to control the validation form the outside.

.m

Roland Zwaga

unread,
Feb 7, 2014, 3:55:36 AM2/7/14
to ang...@googlegroups.com
this is probably what I'll end up doing indeed. For now I need it for one scenario,
but if more pop up along the way, I'll just create a custom ngShow directive to handle
this stuff.
Thanks for your thoughts!

.m

Reply all
Reply to author
Forward
0 new messages