I am just getting started with Angular, and do not have a programming background (I'm a designer, uh-oh). I'm mixing together two PhoneGap starter projects, picking apart their code to fit my idea. I'm trying to reverse-engineer a very simple master-detail app that uses some JSON, and change this so it fetches the data via AJAX. Eventually I would like to store the data in the app once intially fetched, and get it to update any new data from the AJAX source.
At the moment the app has:
module.factory('$data', function() {
var data = {};
data.items = [
{
title: 'A bunch of data',
..etc..
Outside of this (in fact before it), I have written my AJAX call:
module.controller('AppController', ['$scope','$http', function($scope,$http) {
$http({
method: 'GET',
url: 'http://www.my-web-adddress.net/api/blah'
}).then(function successCallback(response) {
var results = response["data"];
for( var i = 0, len = results.length; i < len; i++ ){...
..Where I can then manipulate the data. However I am unsure about passing the data between these two functions, or whether I am best trying to write a single function. If it should be a single function, I am struggling with the factory
vs service
vs controller
conventions, scope, injection, etc, so if someone could give me a quick example about how they would structure it that would be amazing.