R
R
Roman Hinex2015-11-29 09:06:27
Angular
Roman Hinex, 2015-11-29 09:06:27

How to subscribe Angular.js to sockets?

Hey!

When running the script, I need to subscribe the user to notifications, but I need to do this once. The problem is that if processed in the controller, then when you go to another page, the service tries to sign for notifications again, you can screw it up and check it every time, but I don’t think that this makes sense.

Tell me how to execute the code I need once only when Angular is initialized?

I will add, subscription to notifications through the service: Notification.init ()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nicholas, 2015-11-29
@HiNeX

Make a wrapper service for your service in Angular and call initialization in the run block.
You can read about run blocks here: angular dock

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question