Created
July 12, 2016 11:40
-
-
Save khannotations/bdea67f3037b68d0b062dcd0eeeae790 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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