Skip to content

Instantly share code, notes, and snippets.

@khannotations
Created July 12, 2016 11:40
Show Gist options
  • Select an option

  • Save khannotations/bdea67f3037b68d0b062dcd0eeeae790 to your computer and use it in GitHub Desktop.

Select an option

Save khannotations/bdea67f3037b68d0b062dcd0eeeae790 to your computer and use it in GitHub Desktop.
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
$routeProvider.when("/", {
controller: "HomeCtrl",
templateUrl: "/templates/home.html",
});
});
// Controller is the link between your HTML and
// your Javascript (data and functions)
app.controller("HomeCtrl", function($scope, $http){
// $http() returns Promise object.
// That object has a function called 'then'
var promise = $http({
url: "https://www.reddit.com/r/funny.json",
method: "GET",
params: {}
}).then(function(response) {
$scope.posts = response.data.data.children;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment