Answer the question
In order to leave comments, you need to log in
How does uLogin callback use angular controller?
In my personal account, I make the function of linking a social account through uLogin. How to call a controller method in a callback? The design of the widget is custom.
<div id="uLogin" data-ulogin="display=buttons;callback=User.getTokenFromULogin">
<img data-uloginbutton="vkontakte" class="social-account-icon" src="img/icons/vkontakte.png">
<!-- Ещё иконки... -->
</div>
Answer the question
In order to leave comments, you need to log in
In general, somehow solved the problem like this:
/**
* Принимаем токен авторизации Ulogin
*/
function getTokenFromULogin(token) {
$.getJSON("//ulogin.ru/token.php?host=" + encodeURIComponent(window.location.toString()) + "&token=" + token + "&callback=?", function (data) {
data = $.parseJSON(data.toString());
if (!data.error) {
// В <div ui-view="UserPage"></div> у меня загружается стэйт личного кабинета, поэтому получаем его scope
var UserCtrl = angular.element('[ui-view="UserPage"]').scope();
// UserCtrl.User - контроллер пользователя
// AddSocialAccount - метод, который дергает метод фабрики, в котором на сервер уходят данные пользователя от uLogin
UserCtrl.User.AddSocialAccount(data);
}
});
}
DO NOT USE ULOGIN OR ITS ANALOGUES!!!
https://habrahabr.ru/post/238117/
How do you think such services are monetized?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question