angular.module('Instagram')
  .controller('DetailCtrl', function($scope, $rootScope, $location, API) {

    var mediaId = $location.path().split('/').pop();

    // TODO: Move into router resolve
    API.getMediaById(mediaId).success(function(media) {
      console.log(media)
      $scope.photo = media;
    });

    $scope.like = function() {
      API.likeMedia(mediaId)
        .success(function() {
          $scope.hasLiked = true;
        })
        .error(function(data) {
          sweetAlert('Error', data.message, 'error');
        });
    };

    $scope.comment = function() {
      var text = prompt('Leave a Comment')
      API.comment(mediaId, text)
        .success(function() {

        })
        .error(function() {
          sweetAlert('Error', data.message, 'error');
        });
    };

  });
@@ -342,71 +342,8 @@
 ) %7B%0A
-      API.likeMedia(mediaId)%0A        .success(function() %7B%0A    
     
@@ -370,37 +370,46 @@
 true;%0A      
-  %7D)%0A        
+API.likeMedia(mediaId)
 .error(funct
@@ -416,26 +416,24 @@
 ion(data) %7B%0A
-  
         swee
@@ -464,34 +464,32 @@
 sage, 'error');%0A
-  
       %7D);%0A    %7D;
@@ -566,16 +566,18 @@
 omment')
+;%0A
 %0A      A
@@ -605,59 +605,8 @@
 ext)
-%0A        .success(function() %7B%0A%0A        %7D)%0A        
 .err
@@ -613,30 +613,32 @@
 or(function(
+data
 ) %7B%0A
-  
         swee
@@ -673,26 +673,24 @@
 , 'error');%0A
-  
       %7D);%0A  

set hasLiked instantly without waiting for .success call