notes-show-controller.js 478 B

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