Skip to content

Instantly share code, notes, and snippets.

@stewones
Forked from anonymous/gist:33b61b6ba4e21d08265a
Last active August 29, 2015 14:17
Show Gist options
  • Save stewones/6f6155778c10c893aa7b to your computer and use it in GitHub Desktop.
Save stewones/6f6155778c10c893aa7b to your computer and use it in GitHub Desktop.
//factory
app.factory('dataLoad', function($http) {
return {
getData: function() {
return $http.get('data-json.php');
}
}
});
//controller
$scope.items = [];
$scope.get = function () {
var onSuccess = function (result) {
$scope.items = result.data.items;
}
var onFail = function (result) {
console.log(result.data);
}
dataLoad.getData().then(onSuccess, onFail);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment