I have an Angular js application which loads from another application after hitting the link with URL which contains some query string parameters:
http://myDomain/clover/?merchant_id=65AY4FNRE9PSG&employee_id=Z1TZ0S0H758TG&client_id=9WJBRXSF1XM8P&code=c0ae98d6-d13c-2c4d-f601-d2ebd3d58ae9#/login
I want to do 2 things :
Enrollment Functionality: I have REST API for the Enrollment, But I need to send merchant_id , client_id and code which need to Fetch from above URL to the Enrollment API so that Enrollment can be done. And once Enrollment is successful then need to do following step i.e. login
Login to Application : I have REST API for Login also, and need to send employee_id an username and password.
Both these functionalities should happen in page load.
I have bootstraped my Angular app like :
angular.element(document).ready(function () {
angular.bootstrap(document,['mPos']);
});
My Service code is :
mPosServices.factory('mosServiceFactory', function ($http, $rootScope, $cookies, $q) {
return{
loginService: function (userData) {
var loginService = $http({
method: 'get',
data: {
'islogin': true
},
url: 'http://myServiceURL/oauth/token?grant_type=password&client_id=restapp&client_secret=restapp&username=' + userData.username + '&password=' + userData.password
});
return loginService;
},
enroll: function (signupdata) {
var signup = $http({
method: 'post',
data: signupdata,
url: 'http://myServiceURL/merchant/enrollment'
});
return signup;
}
};
});
How should I fetch those URL parameters ao page load ? how should I call $http request on page load so that Enrollment and login can be done?