I am a beginner in both Angular and JavaScript, and I am attempting to incorporate the LinkedIn API into my AngularJS project in order to automatically populate certain forms with data from LinkedIn. I have already tested it by including everything in the same file (in the view) like this:
<script type="in/login" data-onAuth="onLinkedInAuth"> </script>
<script type="text/javascript">
function onLinkedInAuth() {
IN.API
.Raw('/people/~:(id,firstName,lastName,formatted-name,num-connections,location,positions:(id,title,summary,start-date,end-date,is-current,company:(id,name,type,size,industry,ticker)),summary,email-address,specialties)?format=json')
.method('GET')
.result(getResults)
.error(onError)
};
function getResults(result) {
console.log(result);
document.getElementById('full_name').value = result.formattedName || '';
document.getElementById('local').value = result.location.country.code || '';
document.getElementById('summary').value = result.summary || '';
document.getElementById('email_address').value = result.emailAddress || '';
}
function onError(error) {
console.log(error)
}
</script>
But now I want to refactor this code to use services and controllers, something like:
Click LinkedIn Button -> controller -> Service -> linkeInAPI -> service -> controller -> view (populate forms with data, for multiple views in this case).
I have already created a linkedInService.js and linkedInController.js.
The issue is that I am unsure how to proceed with this, as I am new to all of these concepts. Any guidance would be greatly appreciated. Thank you.