Skip to content

Instantly share code, notes, and snippets.

@biagidp
Created February 10, 2015 22:09
Show Gist options
  • Save biagidp/db578f3cd4726c3d0624 to your computer and use it in GitHub Desktop.
Save biagidp/db578f3cd4726c3d0624 to your computer and use it in GitHub Desktop.
Load Schema from json
//Service
angular.module('schemaService', [])
.service('schemaService', function($http, $q){
var deferred = $q.defer();
$http.get('schema.json')
.success(function(res){
deferred.resolve(res.data);
});
return deferred.promise;
});
//code in controller
$scope.schema = {}
$scope.loadSchema = function(){
schemaService.then(function(schema){
$scope.schema = schema;
});
};
$scope.loadSchema();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment