R
R
Rodion Meshcheryakov2014-09-25 16:22:38
Angular
Rodion Meshcheryakov, 2014-09-25 16:22:38

How to organize methods in Angular that are common to several controllers?

Here's an example:
SPA has a login screen and a registration screen. Both screens have their own controllers: LoginCtrl and RegisterCtrl.
On both screens, it is possible to log in through social networks. Accordingly, absolutely identical methods are called: loginFb(), loginVk, etc.
How to get away from duplicating the same methods in different controllers?
Create LoginViaSocial service?
Create an AppCtrl application controller that will be the parent of LoginCtrl and RegisterCtrl, and move methods into it?
UPD
Here is a good post on the topic of the question.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2014-09-25
@rodionme

The philosophy is such that all logic, in my opinion, should be stored in services.
And the controller only connects the interface with these services.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question