Created
September 29, 2015 01:07
-
-
Save chrisckchang/e5e6d7fc59b2b762edec to your computer and use it in GitHub Desktop.
Contact list Angular homepage-specific code
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
angular.module("contactsApp", ['ngRoute']) | |
.config(function($routeProvider) { | |
$routeProvider | |
.when("/", { | |
templateUrl: "list.html", | |
controller: "ListController", | |
resolve: { | |
contacts: function(Contacts) { | |
return Contacts.getContacts(); | |
} | |
} | |
}) | |
}) | |
.service("Contacts", function($http) { | |
this.getContacts = function() { | |
return $http.get("/contacts"). | |
then(function(response) { | |
// XXX - success | |
return response; | |
}, function(response) { | |
alert("Error retrieving contacts."); | |
}); | |
} | |
}) | |
.controller("ListController", function(contacts, $scope) { | |
$scope.contacts = contacts.data; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment