notes-show-controller.js 453 B

1234567891011121314151617
  1. angular.module("noteWrangler")
  2. .controller("NotesShowController", function ($http, $routeParams, $scope) {
  3. const errorHandler = function (err) {
  4. console.log("Error getting /notes", err);
  5. };
  6. const responseHandler = function (data) {
  7. const id = parseInt($routeParams.id, 10);
  8. $scope.note = data.data[id];
  9. };
  10. $http({
  11. method: "GET",
  12. url: "/notes.json"
  13. }).then(responseHandler, errorHandler);
  14. });