Last active
April 17, 2016 04:57
-
-
Save gsans/2587aa2d2d194ff2b966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory("Movies", function($http, $q) { | |
return { | |
get: function() { | |
var deferred = $q.defer(); | |
$http.get('movies.json') | |
.then(function(response){ | |
deferred.resolve(response.data); | |
}) | |
.catch(function(error){ | |
deferred.reject(error); | |
}); | |
return deferred.promise; | |
} | |
} | |
}) | |
... | |
app.controller("MoviesCtrl", function($scope, Movies) { | |
Movies.get().then(function(data){ | |
$scope.movies = data; | |
}) | |
.catch(function(error){ | |
console.log(error); | |
}); | |
}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment