{
  angular.module('marvelousnote.notesForm')
     .controller('NotesFormController', NotesFormController);

  NotesFormController.$inject = ['$state', 'Flash', 'NotesService'];
  function NotesFormController($state, Flash, NotesService) {
    const vm = this;
    vm.note = NotesService.find($state.params.noteId);
    vm.clearForm = clearForm;
    vm.save = save;
    vm.destroy = destroy;

    //////////////////////////

    function clearForm() {
      vm.note = { title: '', body_html: '' };
    }

    function save() {
      if (vm.note._id) {
        NotesService.update(vm.note)
          .then(
            function(res) {
              vm.note = angular.copy(res.data.note);
              Flash.create('success', res.data.message);
              $state.go('notes.form', { noteId: vm.note._id });
            },
            function() {
              Flash.create('danger', 'Oops! Something went wrong.');
            });
      }
      else {
        NotesService.create(vm.note)
          .then(
            function(res) {
              vm.note = res.data.note;
              Flash.create('success', res.data.message);
            },
            function() {
              Flash.create('danger', 'Oops! Something went wrong.');
            });
      }
    }

    function destroy() {
      NotesService.destroy(vm.note)
        .then(function() {
          vm.clearForm();
        });
    }
  }
}

@@ -39,19 +39,16 @@
 sForm')%0A
-   
   .contr
@@ -579,34 +579,32 @@
 m.note)%0A        
-  
 .then(%0A         
@@ -604,36 +604,25 @@
         
-  function(res)
+res =%3E
  %7B%0A
-  
         
@@ -668,34 +668,32 @@
 e);%0A            
-  
 Flash.create('su
@@ -731,18 +731,16 @@
         
- 
- 
 $state.g
@@ -783,34 +783,32 @@
 d %7D);%0A          
-  
 %7D,%0A            f
@@ -808,36 +808,13 @@
     
-  function() %7B%0A             
+() =%3E
  Fla
@@ -859,38 +859,33 @@
 ent wrong.')
-;%0A    
+%0A
         
 %7D);%0A      %7D%0A
@@ -864,33 +864,32 @@
 rong.')%0A        
-%7D
 );%0A      %7D%0A     
@@ -937,26 +937,24 @@
 te)%0A        
-  
 .then(%0A     
@@ -962,28 +962,17 @@
     
-  function(res)
+res =%3E
  %7B%0A
-  
     
@@ -1004,18 +1004,16 @@
 a.note;%0A
-  
         
@@ -1061,34 +1061,32 @@
 age);%0A          
-  
 %7D,%0A            f
@@ -1086,36 +1086,13 @@
     
-  function() %7B%0A             
+() =%3E
  Fla
@@ -1141,17 +1141,16 @@
 wrong.')
-;
 %0A       
@@ -1146,29 +1146,24 @@
 .')%0A        
-    %7D
 );%0A      %7D%0A 
@@ -1239,28 +1239,14 @@
     
-  
 .then(
-function() %7B
 %0A   
@@ -1246,25 +1246,29 @@
 en(%0A        
- 
+() =%3E
  vm.clearFor
@@ -1274,19 +1274,15 @@
 rm()
-;
 %0A      
-  %7D
 );%0A 

Use fat arrow syntax for callbacks.